Open aghassemi opened 9 years ago
@aghassemi just wanted to check that you're aware you can do:
var delegator = new Delegator(),
customEvents = [ 'foo', 'bar', 'baz' ];
customEvents.forEach(function (event) {
delegator.listenTo(event);
});
i realize you're asking for more convenience than that but just wanted to make sure you know that is an option for now.
I am sort of doing this but the issue is I don't have direct access to the delegator instance that is created by Mercury. But Mercury does let me pass options to delegator constructor in the function app()
(see https://github.com/Raynos/mercury/blob/master/index.js) so it would be nice to be able to pass them as part of opts.
My work around relies on the fact that delegator is a singleton and cached, so even-though I don't have access to the delegator instance created by Mercury, doing mercury.Delegator({defaultEvents: false}).listenTo(customEvent)
happens to work due to singleton nature of delegator.
yeah. that's exactly part of why it's a singleton - what you're doing is the way it's expected that you should do it.
Sounds good. Thanks for clarifying.
@aghassemi the delegator is a globally cached singleton for this and other reasons.
That's never going to change.
It would be nice to be able to extend the list of common events that are hard-coded here with just passing a list of custom events as part of the opts.