Class Evented

public
import Evented from '@ember/object/evented';

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

app/utils/person.js
import EmberObject from '@ember/object';
import Evented from '@ember/object/evented';

export default EmberObject.extend(Evented, {
  greet() {
    // ...
    this.trigger('greet');
  }
});
var person = 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);

Show:

Methods

Properties

No documented items

Events

No documented items