Class Ember.Instrumentation

The purpose of the Ember Instrumentation module is to provide efficient, general-purpose instrumentation for Ember.

Subscribe to a listener by using Ember.subscribe:

1
2
3
4
5
6
7
8
9
Ember.subscribe("render", {
  before: function(name, timestamp, payload) {

  },

  after: function(name, timestamp, payload) {

  }
});

If you return a value from the before callback, that same value will be passed as a fourth parameter to the after callback.

Instrument a block of code by using Ember.instrument:

1
2
3
Ember.instrument("render.handlebars", payload, function() {
  // rendering logic
}, binding);

Event names passed to Ember.instrument are namespaced by periods, from more general to more specific. Subscribers can listen for events by whatever level of granularity they are interested in.

In the above example, the event is render.handlebars, and the subscriber listened for all events beginning with render. It would receive callbacks for events named render, render.handlebars, render.container, or even render.handlebars.layout.

Show:

Module: ember-metal
obj
list
String...|Array
of keys to get
returns
Hash

To get multiple properties at once, call Ember.getProperties with an object followed by a list of strings or an array:

1
Ember.getProperties(record, 'firstName', 'lastName', 'zipCode');  // { firstName: 'John', lastName: 'Doe', zipCode: '10011' }

is equivalent to:

1
Ember.getProperties(record, ['firstName', 'lastName', 'zipCode']);  // { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
Module: ember-metal
name
String
Namespaced event name.
payload
Object
callback
Function
Function that you're instrumenting.
binding
Object
Context that instrument function is called with.

Notifies event's subscribers, calls before and after hooks.

Module: ember-metal

Resets Ember.Instrumentation by flushing list of subscribers.

Module: ember-metal
pattern
String
Namespaced event name.
object
Object
Before and After hooks.

Subscribes to a particular event or instrumented block of code.

Module: ember-metal
subscriber
Object

Unsubscribes from a particular event or instrumented block of code.