Skip to content

Commit 974fbe6

Browse files
committed
Updated prose. Added code example for refactoring tryInvoke.
1 parent a8b0023 commit 974fbe6

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

content/ember-3-24-released.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Ember.js is the core framework for building ambitious web applications.
2929

3030
### Changes in Ember.js 3.24
3131

32-
Ember.js 3.24 is an incremental, backwards compatible release of Ember with bugfixes, performance improvements, and minor deprecations.
32+
Ember.js 3.24 is an incremental, backwards compatible release of Ember with bug fixes, performance improvements, and minor deprecations.
3333

3434
#### Bug Fixes
3535

@@ -54,22 +54,54 @@ Ember.js 3.24 introduced 4 deprecations.
5454

5555
1. Going back to the interface of `DeprecationOptions` (see Features above), forgetting to pass `for` or `since` will trigger a deprecation message. ([#19133](https://github.com/emberjs/ember.js/pull/19133))
5656
2. `Ember.String.loc` function, `@ember/string#loc` function, and `{{loc}}` helper have been deprecated in favor of a dedicated localization solution like [ember-intl](https://github.com/ember-intl/ember-intl). For more information, please see the [Deprecations Guide](https://deprecations.emberjs.com/v3.x/#toc_ember-string-loc). ([#19211](https://github.com/emberjs/ember.js/pull/19211))
57-
3. Calling an [`Ember.String` method](https://api.emberjs.com/ember/3.23/classes/String)`camelize`, `capitalize`, `classify`, `dasherize`, `decamelize`, `underscore`, or `w`directly on a string is deprecated. Instead of calling the method on the string, you can import the function from `@ember/string`:
57+
3. Calling `camelize`, `capitalize`, `classify`, `dasherize`, `decamelize`, `underscore`, or `w`these are [`Ember.String` methods](https://api.emberjs.com/ember/3.23/classes/String)on a string is deprecated. Instead of calling the method on the string, you can import the function from `@ember/string`:
5858

5959
```javascript
6060
// Before
6161
let mascot = 'Empress Zoey';
62+
6263
console.log(mascot.camelize()); // empressZoey
6364

6465
// After
6566
import { camelize } from '@ember/string';
6667

6768
let mascot = 'Empress Zoey';
69+
6870
console.log(camelize(mascot)); // empressZoey
6971
```
7072

7173
For more information, please see the [Deprecations Guide](https://deprecations.emberjs.com/v3.x/#toc_ember-string-prototype-extensions). ([#19234](https://github.com/emberjs/ember.js/pull/19234))
72-
4. Use of `tryInvoke` from `@ember/utils` module has been deprecated in favor of using JavaScript's optional chaining `?.`. For more information, please see the [Deprecations Guide](https://deprecations.emberjs.com/v3.x#toc_ember-utils-try-invoke).
74+
4. `tryInvoke` from `@ember/utils` module has been deprecated in favor of JavaScript's optional chaining `?.`.
75+
76+
```javascript
77+
// Before
78+
import { tryInvoke } from '@ember/utils';
79+
80+
let today = new Date('01/07/2021');
81+
82+
tryInvoke(today, 'getTime'); // 1609974000000
83+
tryInvoke(today, 'setFullYear', [2014]); // 1389049200000
84+
tryInvoke(today, 'noSuchMethod', [2014]); // undefined
85+
86+
// After
87+
let today = new Date('01/07/2021');
88+
89+
today.getTime?.(); // 1609974000000
90+
today.setFullYear?.(2014); // 1389049200000
91+
today.noSuchMethod?.(2014); // undefined
92+
93+
/*
94+
Note, `today` is used in the context of `tryInvoke`.
95+
As a result, we can assume that `today` is an object
96+
and write `today.getTime` instead of `today?.getTime`.
97+
98+
The examples exist only to illustrate how to refactor
99+
`tryInvoke`. Please don't write `today.getTime?.()`
100+
in practice. :)
101+
*/
102+
```
103+
104+
For more information, please see the [Deprecations Guide](https://deprecations.emberjs.com/v3.x#toc_ember-utils-try-invoke).
73105

74106
Deprecations are added to Ember.js when an API will be removed at a later date. Each deprecation has an entry in the deprecation guide describing the migration path to a more stable API. Deprecated public APIs are not removed until a major release of the framework.
75107

0 commit comments

Comments
 (0)