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

State sharing between Python and Javascript #1594

Open
r0x0r opened this issue Feb 6, 2025 · 0 comments
Open

State sharing between Python and Javascript #1594

r0x0r opened this issue Feb 6, 2025 · 0 comments

Comments

@r0x0r
Copy link
Owner

r0x0r commented Feb 6, 2025

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 and Window.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) and window.state += lambda 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

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

1 participant