Ember.Evented Class
PUBLIC
Defined in: packages/ember-runtime/lib/mixins/evented.js:14
Module: ember-runtime
This mixin allows for Ember objects to subscribe to and emit events.
App.Person = Ember.Object.extend(Ember.Evented, { greet: function() { // ... this.trigger('greet'); } }); var person = App.Person.create(); person.on('greet', function() { console.log('Our person has greeted'); }); person.greet(); // outputs: 'Our person has greeted'
You can also chain multiple event subscriptions:
person.on('greet', function() { console.log('Our person has greeted'); }).one('greet', function() { console.log('Offer one-time special'); }).off('event', this, forgetThis);
Please login to continue.