Class Evented

public
Defined in: packages/ember-runtime/lib/mixins/evented.js:13
Module: @ember/object
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);

Methods

Properties

No documented items

Events

No documented items

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