Giter Site home page Giter Site logo

Comments (4)

Raynos avatar Raynos commented on June 9, 2024

@neonstalwart the motivation for the id is namespacing.

It allows the application to have multiple delegator instances which means you can nest applications in applications. The reason the id is needed is because dom-delegator has a global event listener on document.body so it cant handle all events, it must only handle events with its own id.

Removing the id breaks recursive modularity.

That said a PR on event-sinks to make the id optional is fine.

Having the notion that a Sink has an id is also useful. It means you can serialize a sink to id:key and know it came from EventSinks(id, [key]).sinks[key]

from mercury.

neonstalwart avatar neonstalwart commented on June 9, 2024

what about using a weakmap to map the delegator instance to the events for this delegator on a node? addEvent(delegator, target, type, handler) i.e. use the target as a key to get a hash and then use the type as a key to get another weakmap which will let you use the delegator as a key to get the handler.

wouldn't that eliminate the need for the id to be passed around everywhere?

from mercury.

Raynos avatar Raynos commented on June 9, 2024

@neonstalwart the problem with that interface is that you now have to pass an instanceof delegator into the render(state) function.

The reason that I had this id is so that you can call addEvent(myAppNamespace, ...) in render.js and call EventSink(myAppNamespace).on(eventName, ...) in input.js

This way the two files (rendering) and (handling user input) are completely seperate and do not have references to each other. Other then a shared id.

My implementation actually embeds the shared id on the sink so you never see the id in the rendering function. Although you still see the id in the input handling code.

from mercury.

neonstalwart avatar neonstalwart commented on June 9, 2024

ok, i might still think on this for a while because even though i see the need for the id, it feels awkward to need to provide it when you use some of these APIs without dom-delegator but i'll close this for now.

from mercury.

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.