From ff1bb486c0cfba21772e7427782244caa8cb88b6 Mon Sep 17 00:00:00 2001 From: gheoan Date: Mon, 18 Sep 2017 02:22:13 +0300 Subject: [PATCH] doc(activation-strategy): improve activation strategy doc --- doc/article/en-US/cheat-sheet.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/article/en-US/cheat-sheet.md b/doc/article/en-US/cheat-sheet.md index 337ac6d5..d3016a2d 100644 --- a/doc/article/en-US/cheat-sheet.md +++ b/doc/article/en-US/cheat-sheet.md @@ -1113,14 +1113,11 @@ Add [a base tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) > Warning > PushState requires server-side support. Don't forget to configure your server appropriately. -### Reusing an existing VM +### Reusing an Existing View Model -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. +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. -> Info -> 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. - - + //app.js @@ -1139,7 +1136,7 @@ Since the VM's navigation life-cycle is called only once you may have problems r import {activationStrategy} from 'aurelia-router'; export class Product { - determineActivationStrategy(){ + determineActivationStrategy() { return activationStrategy.replace; } } @@ -1161,16 +1158,19 @@ Since the VM's navigation life-cycle is called only once you may have problems r //product.ts - import {activationStrategy} from 'aurelia-router'; + import {activationStrategy, RoutableComponentDetermineActivationStrategy} from 'aurelia-router'; - export class Product { - determineActivationStrategy(): string { + export class Product implements RoutableComponentDetermineActivationStrategy { + determineActivationStrategy() { return activationStrategy.replace; } } +> Info +> 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. + ### Rendering multiple ViewPorts > Info