Ember.assert()

assert (desc, test) public

Defined in packages/ember-debug/lib/index.js:33

Define an assertion that will throw an exception if the condition is not met.

  • In a production build, this method is defined as an empty function (NOP). Uses of this method in Ember itself are stripped from the ember.prod.js build.
// Test for truthiness
Ember.assert('Must pass a valid object', obj);

// Fail unconditionally
Ember.assert('This code path should never be run');

Parameters:

desc String
A description of the assertion. This will become the text of the Error thrown if the assertion fails.
test Boolean
Must be truthy for the assertion to pass. If falsy, an exception will be thrown.
doc_EmberJs
2016-11-30 16:51:07
Comments
Leave a Comment

Please login to continue.