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

Pattern for handling global dom events #284

Closed
vi4m opened this issue Oct 6, 2020 · 1 comment · Fixed by #288
Closed

Pattern for handling global dom events #284

vi4m opened this issue Oct 6, 2020 · 1 comment · Fixed by #288
Assignees
Labels
documentation Technical writing, references, tutorials etc

Comments

@vi4m
Copy link

vi4m commented Oct 6, 2020

I'm looking for a pattern for handling global javascript/dom events, such as handling back button navigation ("window.onpopstate").
The reason was to workaround navigation problems with wasm apps, with pushState and popState.

I tried various scenarious, based on https://github.com/TokamakUI/Tokamak/blob/main/Sources/TokamakDOM/App/ColorSchemeObserver.swift, and:

  • it compiles fine
  • the event defined in JSClosure is fired, but when I'm sending new value to publisher, it's not received by destination View no matter if I use ObservedObject, or low level publisher + sink.

Looks like some magic sauce is needed to communicate from JSClosure which I'm missing.

Can you provide some example how to do it?

@MaxDesiatov MaxDesiatov added the documentation Technical writing, references, tutorials etc label Oct 6, 2020
@MaxDesiatov MaxDesiatov self-assigned this Oct 6, 2020
@MaxDesiatov
Copy link
Collaborator

Thanks for opening the issue, I'll be able to have a look later today and will provide some example code.

MaxDesiatov added a commit that referenced this issue Oct 6, 2020
MaxDesiatov added a commit that referenced this issue Oct 6, 2020
* Add `URLHashDemo` w/ `window.onhashchange` closure

Resolves #284

* Assign `.undefined` in HashState.deinit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Technical writing, references, tutorials etc
Development

Successfully merging a pull request may close this issue.

2 participants