Debug

Ember.Debug Class

PUBLIC

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

Module: ember-debug

registerDeprecationHandler (handler) publicstatic

Defined in packages/ember-debug/lib/index.js:229
Available since 2.1.0

Allows for runtime registration of handler functions that override the default deprecation behavior. Deprecations are invoked by calls to Ember.deprecate. The following example demonstrates its usage by registering a handler that throws an error if the message contains the word "should", otherwise defers to the default handler.

Ember.Debug.registerDeprecationHandler((message, options, next) => {
  if (message.indexOf('should') !== -1) {
    throw new Error(`Deprecation message with should: ${message}`);
  } else {
    // defer to whatever handler was registered before this one
    next(message, options);
  }
});

The handler function takes the following arguments:

  • message - The message received from the deprecation call.
  • options - An object passed in with the deprecation call containing additional information including:
    • id - An id of the deprecation in the form of package-name.specific-deprecation.
    • until - The Ember version number the feature and deprecation will be removed in.
  • next - A function that calls into the previously registered handler.

Parameters:

handler Function
A function to handle deprecation calls.

registerWarnHandler (handler) publicstatic

Defined in packages/ember-debug/lib/index.js:265
Available since 2.1.0

Allows for runtime registration of handler functions that override the default warning behavior. Warnings are invoked by calls made to Ember.warn. The following example demonstrates its usage by registering a handler that does nothing overriding Ember's default warning behavior.

// next is not called, so no warnings get the default behavior
Ember.Debug.registerWarnHandler(() => {});

The handler function takes the following arguments:

  • message - The message received from the warn call.
  • options - An object passed in with the warn call containing additional information including:
    • id - An id of the warning in the form of package-name.specific-warning.
  • next - A function that calls into the previously registered handler.

Parameters:

handler Function
A function to handle warnings.

© 2017 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://emberjs.com/api/classes/Ember.Debug.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部