| Module: | @ember/debug |
|---|
Defined in packages/@ember/debug/lib/deprecate.ts:37
Available since v2.1.0
import { registerDeprecationHandler } from '@ember/debug'; Allows for runtime registration of handler functions that override the default deprecation behavior. Deprecations are invoked by calls to @ember/debug/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.
import { registerDeprecationHandler } from '@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.
© 2022 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/4.9/functions/@ember%2Fdebug/registerDeprecationHandler