Ember.Evented

public

This mixin allows for Ember objects to subscribe to and emit events.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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:

1
2
3
4
5
person.on('greet', function() {
  console.log('Our person has greeted');
}).one('greet', function() {
  console.log('Offer one-time special');
}).off('event', this, forgetThis);

Show:

Methods

Properties

No documented items

Events

No documented items