baseprime / grapnel

The smallest JavaScript router with named parameters, HTML5 pushState, and middleware support
http://grapnel.js.org
467 stars 40 forks source link

multiple events not triggered when delimited by a space #34

Closed cvan closed 9 years ago

cvan commented 9 years ago

although the docs/comments suggest it can be done, multiple events cannot be called when separated by a space.

trigger Triggers an event

/**
 * @param {String} event name (multiple events can be called when seperated by a space " ")
 * @param {Mixed} [attributes] Parameters that will be applied to event handler
*/
router.trigger('event otherevent', eventArg1, eventArg2);
baseprime commented 9 years ago

The issue is that router.trigger wasn't initially meant to trigger more than 1 event. The reason this was believed was because the JavaDoc was copied from router.bind, but the functionality did not follow. So that's my fault. That's what I get for copying and pasting JavaDoc! :]

Thanks for bringing this up, it also made me realize that there was a typo in README.md.

cvan commented 9 years ago

you don't want to allow router.trigger to trigger multiple events? could be be nice

baseprime commented 9 years ago

Generally, a developer should be binding to multiple, but triggering once. This prevents event emitters from getting out of hand. Barring firing multiple events for compatibility issues, the app only needs to be emitting events once per line. If you really need to, you can call it multiple times. router.trigger().trigger();

cvan commented 9 years ago

yep, that's how I'm doing it now - okay, no worries