W3cubDocs

/Ember.js

Ember.Evented (public)

Defined in: packages/ember-runtime/lib/mixins/evented.js:14
Module: ember

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);

Methods

Properties

No documented items

Events

No documented items

© 2017 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://emberjs.com/api/ember/2.14/classes/Ember.Evented