Skip to content
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

Persistent State Components #34

Closed
Archmonger opened this issue Oct 27, 2021 · 2 comments
Closed

Persistent State Components #34

Archmonger opened this issue Oct 27, 2021 · 2 comments

Comments

@Archmonger
Copy link
Contributor

Current Situation

Currently, component state is lost upon websocket reconnect. This forces a re-render from the base state.

Proposed Changes

Configure some method to save off the current state of the component

Implementation Details

Implement as an opt-in feature. Might be implemented as an alternative to use_state (for example, use_persistent_state) or as a decorator @idom.persistent_component.

Storing the state

  • Use dill to pickle whatever is currently within state upon each set_state mutation.
  • State can be stored client side within sessionStorage.

Communicating the state back to the server

  • Need to develop some method of preventing the first render if the browser currently has a stored state.
  • When the pickled data is transported back as json, it will need to somehow be automatically put back into the state

Avoid state spoofing

  • If a component state contains something like "is_admin", it would be pretty trivial to spoof this.
  • Need to ensure the browser owns the state it says it does (if state is stored client sided)
  • Need to ensure the state has been unmodified since last connection (if state is stored client sided)
@Archmonger
Copy link
Contributor Author

Archmonger commented Oct 28, 2021

Due to the risks of client-side state spoofing, this implementation may only be reasonable as a server-side database backed feature.

Blindly trusting a client's state could get risky.

@rmorshea rmorshea transferred this issue from reactive-python/reactpy Jan 9, 2022
@rmorshea
Copy link
Contributor

rmorshea commented Jan 9, 2022

closed in favor of #33 and #32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants