Skip to content

Commit b440ed0

Browse files
authored
update docs to use the @action decorator (#9)
update docs to use the @action decorator
2 parents 48faeb4 + 2ae4413 commit b440ed0

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

addon/modifiers/did-insert.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ import Ember from 'ember';
2222
```
2323
2424
By default, the executed function will be unbound. If you would like to access
25-
the component context in your function, use the `action` helper as follows:
25+
the component context in your function, use the `action` decorator as follows:
2626
2727
```handlebars
28-
<div {{did-insert (action this.incrementCount)}}>first</div>
29-
<div {{did-insert (action this.incrementCount)}}>second</div>
28+
<div {{did-insert this.incrementCount}}>first</div>
29+
<div {{did-insert this.incrementCount}}>second</div>
3030
3131
<p>{{this.count}} elements were rendered</p>
3232
```
3333
34-
```js
34+
```js
3535
export default Component.extend({
36-
@tracked count = 0;
36+
count: tracked({ value: 0 }),
3737
38-
incrementCount() {
38+
incrementCount: action(function() {
3939
this.count++;
40-
}
40+
})
4141
});
4242
```
4343

addon/modifiers/did-update.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,18 @@ import Ember from 'ember';
3939
```
4040
4141
By default, the executed function will be unbound. If you would like to access
42-
the component context in your function, use the `action` helper as follows:
42+
the component context in your function, use the `action` decorator as follows:
4343
4444
```handlebars
45-
<div {{did-update (action this.someFunction) @someArg} />
45+
<div {{did-update this.someFunction @someArg} />
46+
```
47+
48+
```js
49+
export default Component.extend({
50+
someFunction: action(function(element, [someArg]) {
51+
// the `this` context will be the component instance
52+
})
53+
});
4654
```
4755
4856
@method did-update

addon/modifiers/will-destroy.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,22 @@ import Ember from 'ember';
1919
```
2020
2121
By default, the executed function will be unbound. If you would like to access
22-
the component context in your function, use the `action` helper as follows:
22+
the component context in your function, use the `action` decorator as follows:
2323
24-
```handlebars
25-
<div {{will-destroy (action this.teardownPlugin)}}>
24+
```handlebars
25+
<div {{will-destroy this.teardownPlugin}}>
2626
{{yield}}
2727
</div>
2828
```
2929
30+
```js
31+
export default Component.extend({
32+
teardownPlugin: action(function(element) {
33+
// the `this` context will be the component instance
34+
})
35+
});
36+
```
37+
3038
@method will-destroy
3139
@public
3240
*/

0 commit comments

Comments
 (0)