-
-
Notifications
You must be signed in to change notification settings - Fork 583
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
State sharing between Python and Javascript #1594
Comments
As far as I am concerned, basic implementation is done now. Latest changes are pushed into the One limitation of the current version is that it detects changes only on the window.state.nested_counter = {
'counter': 0
}
window.state.nested_counter['counter'] = 1 # this goes undetected I have attempted to solve this with two different approaches
sub_state = State({'counter': 0})
window.state.nested_counter = sub_state
sub_state.counter = 1 # this will be detected Sub-states have exactly same API as the main state Anyhow neither of these approaches are implemented, nor will be for the 6.0. It remains to be seen if this feature is needed. Another feature that might be introduced in the future is global state, a state object which can be shared between different windows. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hello, Thank you for this feature. Is there a release date for 6.0 ? |
@jeanbaptiste444 sometime later this year. There are a few things left to be implemented. |
The next major version of pywebview will introduce state - a way to seamlessly share data between Python and Javascript. State is represented by the
pywebview.state
object in Javascript andWindow.state
object in Python. Updating a property on either object will update its value on the other side. An example can be found here.Additionally, each state object emits an event when state is updated. Implementation details are not set in stone, but currently the syntax is
pywebview.state.addEventHandler('change', handler)
andwindow.state += lambda event_type, key, value: pass
State is implemented by means of a proxy in Javascript and an observable class in Python.
The current ahem state can be tracked in the store branch
Ideas, suggestions or questions are welcomed
The text was updated successfully, but these errors were encountered: