chinedufn / percy

Build frontend browser apps with Rust + WebAssembly. Supports server side rendering.
https://chinedufn.github.io/percy/
Apache License 2.0
2.28k stars 84 forks source link

Isomorphic Example – Where to Add Event Listeners #122

Closed murtyjones closed 5 years ago

murtyjones commented 5 years ago

Am I right in thinking that document event listeners (e.g. listening for clicks on the body element) can be added only in the client crate of the isomorphic example? Reason being there will be runtime errors server-side when trying to add an event listener in the app crate

chinedufn commented 5 years ago

Yup exactly right!

In almost all cases - unless there is some large ergonomics benefit - browser specific things should happen in the web-client and then be passed into or msg'd into the app.

This makes it easier to have an ios-client or electron-client in the future.

Closing since you were spot on - let me know if there are any other questions here!

The real answer is to just continue to update the example code and its comments over time so that all of these questions are answered for people ..