Comments (4)
@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.
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.
@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.
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)
- live component reloading HOT 6
- Mercury not exporting virtual-hyperscript SVG HOT 2
- Immutable props
- question: how to detect if a widget has been unmounted HOT 2
- Communication between child components
- Why static render methods? HOT 3
- Using vdom-to-html doesn't work (returns empty string) HOT 6
- Redux + mercury example? HOT 10
- lock down wiki?
- syntax of h HOT 2
- npm install fails HOT 1
- 14.1.0 break all VNode input rendering HOT 8
- newb question HOT 4
- Docs/Introduction: Simple Cycle example missing
- Synchronize tagged version and comment in mercury.js
- Rendering subitems of different types HOT 4
- What is the right way to pass data to click event handlers? HOT 1
- Get the previous version of state var HOT 3
- Splitting components out to their own render loop? HOT 2
- How to attach state to renderer? HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mercury.