Backbone events with wildcards
backbone.js, javascript
Solution
No. Backbone typically fires a general `eventName` event, as well as `eventName:specifier` event. An example of this is `Model.change`, which allows you to listen to all changes, as well as changes to individual fields:
model.on('change', this.onAnyPropertyChanged);
model.on('change:name', this.onNamePropertyChanged);
Following this pattern in your code, you could trigger your events as follows:
app.vent.trigger('notification', 'info');
app.vent.trigger('notification:info');
And listen to the general event:
app.vent.on('notification', function(type){
console.log(type); //-> "info"
});
Problem
Is there a way to listen to all events of a namespace. So when I listen to an event like this: ``` app.vent.on('notification(:id)', function(type){console.lof(type)}) ``` It will listen to all events likes this: ``` app.vent.trigger('notification:info') app.vent.trigger('notification:error') app.vent.trigger('notification:success') ```