New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client-side state should be directly accessible #165
Comments
For people who land here, see the Gist below for a prototype implementation of a SessionState module that solves this issue: Usage:
Please note: the |
I would like to use this feature in a script that runs report that takes a long time to complete. Because of this I can't rerun the report (remote data fetching and running statistical analysis) every time one of many input fields are changed. Code Example# multiple input fields and a "Run" button to execute the report
cfg = {}
cfg['start'] = st.date_input('Start date')
cfg['end'] = st.date_input('End date')
cfg['client'] = st.text_input('Client')
run = st.button('Run Report')
# update the stored config to the current inputs only
# when the "Run Report" button is clicked
if run:
st.set_state('config', cfg)
report_config = st.get_state('config')
result = report(report_config)
# the long running report function that needs a
# stable input config for caching
@st.cache
def report(config):
... If I would call We currently have something like this implemented where the configuration is stored in a file. This only works for one user though. I would expect this functionality to have a separate state storage per browser tab. |
Closing, as state management is actively being developed, and product discussion underway |
Problem
We want to make stateful apps possible in Streamlit by making the client state directly accessible. This would enable, for example, the following two scenarios which using hypothetical notation (see Possible API Proposals for more possibilities).
Scenario 1: A Simple Counter
This is a classic React example is the counter:
Scenario 2: State Constraints Between Widgets
Suppose we have a "start date" and "end date," and wants to ensure that the former comes before the latter:
Note
The feature request from the old repo has a lot more information.
Summary
The correct design has not been decided. Please indicate your use case for this feature as a comment below!
The text was updated successfully, but these errors were encountered: