Skip to content

Commit ff1bb48

Browse files
committed
doc(activation-strategy): improve activation strategy doc
1 parent 71a443b commit ff1bb48

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

doc/article/en-US/cheat-sheet.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,14 +1113,11 @@ Add [a base tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base)
11131113
> Warning
11141114
> PushState requires server-side support. Don't forget to configure your server appropriately.
11151115
1116-
### Reusing an existing VM
1116+
### Reusing an Existing View Model
11171117

1118-
Since the VM's navigation life-cycle is called only once you may have problems recognizing that the user switched the route from `Product A` to `Product B` (see below). To work around this issue implement the method `determineActivationStrategy` in your VM and return hints for the router about what you'd like to happen.
1118+
Since the view model's navigation lifecycle is called only once, you may have problems recognizing that the user switched the route from `Product A` to `Product B` (see below). To work around this issue implement the method `determineActivationStrategy` in your view model and return hints for the router about what you'd like to happen. Available return values are `replace` and `invoke-lifecycle`. Remember, "lifecycle" refers to the navigation lifecycle.
11191119

1120-
> Info
1121-
> Additionally, you can add an `activationStrategy` property to your route config if the strategy is always the same and you don't want that to be in your view-model code. Available values are `replace` and `invoke-lifecycle`. Remember, "lifecycle" refers to the navigation lifecycle.
1122-
1123-
<code-listing heading="Router VM Activation Control">
1120+
<code-listing heading="Router View Model Activation Control">
11241121
<source-code lang="ES 2015/2016">
11251122
//app.js
11261123

@@ -1139,7 +1136,7 @@ Since the VM's navigation life-cycle is called only once you may have problems r
11391136
import {activationStrategy} from 'aurelia-router';
11401137

11411138
export class Product {
1142-
determineActivationStrategy(){
1139+
determineActivationStrategy() {
11431140
return activationStrategy.replace;
11441141
}
11451142
}
@@ -1161,16 +1158,19 @@ Since the VM's navigation life-cycle is called only once you may have problems r
11611158

11621159
//product.ts
11631160

1164-
import {activationStrategy} from 'aurelia-router';
1161+
import {activationStrategy, RoutableComponentDetermineActivationStrategy} from 'aurelia-router';
11651162

1166-
export class Product {
1167-
determineActivationStrategy(): string {
1163+
export class Product implements RoutableComponentDetermineActivationStrategy {
1164+
determineActivationStrategy() {
11681165
return activationStrategy.replace;
11691166
}
11701167
}
11711168
</source-code>
11721169
</code-listing>
11731170

1171+
> Info
1172+
> Alternatively, if the strategy is always the same and you don't want that to be in your view model code, you can add the `activationStrategy` property to your route config instead.
1173+
11741174
### Rendering multiple ViewPorts
11751175

11761176
> Info

0 commit comments

Comments
 (0)