Skip to content

Commit

Permalink
Merge pull request #19645 from nlfurniss/remove-try-invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
mixonic committed Jul 18, 2021
2 parents 5beb333 + c1aee95 commit dd89193
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 116 deletions.
2 changes: 1 addition & 1 deletion packages/@ember/-internals/utils/index.ts
Expand Up @@ -23,7 +23,7 @@ export {
} from './lib/super';
export { default as inspect } from './lib/inspect';
export { default as lookupDescriptor } from './lib/lookup-descriptor';
export { canInvoke, tryInvoke } from './lib/invoke';
export { canInvoke } from './lib/invoke';
export { default as makeArray } from './lib/make-array';
export { getName, setName } from './lib/name';
export { default as toString } from './lib/to-string';
Expand Down
51 changes: 0 additions & 51 deletions packages/@ember/-internals/utils/lib/invoke.ts
@@ -1,5 +1,3 @@
import { deprecate } from '@ember/debug';

/**
Checks to see if the `methodName` exists on the `obj`.
Expand All @@ -25,52 +23,3 @@ export function canInvoke(obj: any | null | undefined, methodName: string): obj
/**
@module @ember/utils
*/

/**
Checks to see if the `methodName` exists on the `obj`,
and if it does, invokes it with the arguments passed.
```javascript
import { tryInvoke } from '@ember/utils';
let d = new Date('03/15/2013');
tryInvoke(d, 'getTime'); // 1363320000000
tryInvoke(d, 'setFullYear', [2014]); // 1394856000000
tryInvoke(d, 'noSuchMethod', [2014]); // undefined
```
@method tryInvoke
@for @ember/utils
@static
@param {Object} obj The object to check for the method
@param {String} methodName The method name to check for
@param {Array} [args] The arguments to pass to the method
@return {*} the return value of the invoked method or undefined if it cannot be invoked
@public
@deprecated Use Javascript's optional chaining instead.
*/
export function tryInvoke(
obj: any | undefined | null,
methodName: string,
args: Array<any | undefined | null>
) {
deprecate(
`Use of tryInvoke is deprecated. Instead, consider using JavaScript's optional chaining.`,
false,
{
id: 'ember-utils.try-invoke',
until: '4.0.0',
for: 'ember-source',
since: {
enabled: '3.24.0',
},
url: 'https://deprecations.emberjs.com/v3.x#toc_ember-utils-try-invoke',
}
);

if (canInvoke(obj, methodName)) {
let method = obj[methodName];
return method.apply(obj, args);
}
}
60 changes: 0 additions & 60 deletions packages/@ember/-internals/utils/tests/try_invoke_test.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/@ember/utils/index.js
@@ -1,3 +1,2 @@
export { isNone, isBlank, isEmpty, isPresent } from '@ember/-internals/metal';
export { tryInvoke } from '@ember/-internals/utils';
export { compare, isEqual, typeOf } from '@ember/-internals/runtime';
1 change: 0 additions & 1 deletion packages/ember/index.js
Expand Up @@ -220,7 +220,6 @@ Ember.guidFor = utils.guidFor;
Ember.inspect = utils.inspect;
Ember.makeArray = utils.makeArray;
Ember.canInvoke = utils.canInvoke;
Ember.tryInvoke = utils.tryInvoke;
Ember.wrap = utils.wrap;
Ember.uuid = utils.uuid;

Expand Down
1 change: 0 additions & 1 deletion packages/ember/tests/reexports_test.js
Expand Up @@ -463,7 +463,6 @@ let allExports = [
['isEqual', '@ember/utils', 'isEqual'],
['isNone', '@ember/utils', 'isNone'],
['isPresent', '@ember/utils', 'isPresent'],
['tryInvoke', '@ember/utils', 'tryInvoke'],
['typeOf', '@ember/utils', 'typeOf'],

// @ember/version
Expand Down
1 change: 0 additions & 1 deletion tests/docs/expected.js
Expand Up @@ -571,7 +571,6 @@ module.exports = {
'trigger',
'triggerAction',
'triggerEvent',
'tryInvoke',
'trySet',
'type',
'typeInjection',
Expand Down

0 comments on commit dd89193

Please sign in to comment.