GithubHelp home page GithubHelp logo

Event binding about pokedex.org HOT 4 OPEN

nolanlawson avatar nolanlawson commented on September 20, 2024
Event binding

from pokedex.org.

Comments (4)

nolanlawson avatar nolanlawson commented on September 20, 2024

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?

from pokedex.org.

FrigoEU avatar FrigoEU commented on September 20, 2024

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.

from pokedex.org.

nolanlawson avatar nolanlawson commented on September 20, 2024

Then on the UI thread side there'd be just a simple event handler that sends the number back to the web worker.

That's pretty much what promise-worker does. :)

from pokedex.org.

FrigoEU avatar FrigoEU commented on September 20, 2024

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.

from pokedex.org.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.