Events

Using JSData with your event-driven architecture

The Store and any Resources you define each are their own event bus. They support the emit, on, and off methods. A number of Model Lifecycle events are fired on Resources. Here they are:

  • DS.beforeCreate
  • DS.afterCreate
  • DS.beforeUpdate
  • DS.afterUpdate
  • DS.beforeDestroy
  • DS.afterDestroy
  • DS.beforeInject
  • DS.afterInject
  • DS.beforeEject
  • DS.afterEject
  • DS.beforeReap
  • DS.afterReap

The DS.change fires on a Resource whenever any item in the Store for that Resource changes.

If instanceEvents is true (the default), then instances will also fire their own DS.change event when they change, similar to the change event fired by instances of Backbone.Model.

The events are useful if you build your app with an event-driven architecture, such as React's Flux pattern.