« All deprecation guides
Deprecation Guide for tryInvoke from @ember/utils
until: 4.0.0
id: ember-utils.try-invoke
tryInvoke
from the @ember/utils
package is now deprecated.
In most cases, function arguments should not be optional, but in the rare occasion that an argument is optional by design, we can replace tryInvoke
with JavaScript's optional chaining.
Before:
import { tryInvoke } from '@ember/utils';
foo() {
tryInvoke(this.args, 'bar', ['baz']);
}
After:
foo() {
this.args.bar?.('baz');
}