-
Notifications
You must be signed in to change notification settings - Fork 325
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
Event binding #42
Comments
Yes, I have been thinking about it a bit. I have a small module that I was planning on incorporating eventually: https://github.com/nolanlawson/promise-worker However, it may be inappropriate because actually the sender of the WW message and the receiver are not necessarily the same component. In general I actually really like the event handler model (simple, vanilla, less code, more obvious); is there another approach you think would be better? |
I'm looking at this more from 'the other side' : I'd like the code in the web worker to register event handlers. I think having your render functions also register the event handlers is, for me at least, much more natural. As for how this would work: serializing functions is impossible, but I was thinking about another step in the vdom process that would walk the vtree and replace every function with a unique string or number, plus add this to a map from unique id -> function. Then on the UI thread side there'd be just a simple event handler that sends the number back to the web worker. The web worker can then consult the map and find which function to execute. This is just a conceptual overview, there are some annoying things to take care of in an actual implementation, but I do think this could work. |
That's pretty much what promise-worker does. :) |
Oooh yeah, I hadn't looked into the implementation of promise-worker but it's definitely a similar line of thought! I don't think promise-worker itself could help with this "issue" though. |
Hey, I love the app and tech behind it!
One thing that's been bugging me though is how event handlers are being bound. I don't mean this in a bad way, it works perfectly for this app, but for more complicated applications, especially ones that incorporate routing, I think this way of working will rapidly become too hard to manage.
I've been thinking about ways to be able to declare your event handlers on the web worker side. Not being able to serialize functions is obviously a problem but I feel that it might be solvable, even though i haven't really come to a good conclusion. Once I have a proof of concept of what I'm thinking about I'll post it here, but I'm just wondering if this is something that you've been thinking about?
The text was updated successfully, but these errors were encountered: