Question

I'm using event aggregator.

Concept is simple enough.

Views subscribes to an event.
Other Views trigger the event.

Now I wonder if there's a way to subscribe/trigger the event with an id.

i.e. View1 of ViewA class tells the global event aggregator that he is interested in eventA and his (model's) id is 1.

View2 of ViewB class triggers the eventA with id 1 so that View1 only can receive the event.
(All other ViewA instances don't get the events)

Was it helpful?

Solution

Could you use event namespacing here? I think this is what delegateEvents in Backbone does.

Say when you subscribe, subscribe for "event.1" (1 is id), and when trigger use same "event.1", in case if you want others to listen for the same event, then make them subscribe to "event" skipping id.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top