Skip to content

Commit 76c5254

Browse files
committed
update docs
1 parent bfc2cea commit 76c5254

File tree

12 files changed

+34
-10
lines changed

12 files changed

+34
-10
lines changed

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@
2626
- [router.redirect](api/redirect.md)
2727
- [router.alias](api/alias.md)
2828
- [router.beforeEach](api/before-each.md)
29+
- [router.afterEach](api/after-each.md)

docs/api/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
- [router.redirect](redirect.md)
1111
- [router.alias](alias.md)
1212
- [router.beforeEach](before-each.md)
13+
- [router.afterEach](after-each.md)

docs/api/after-each.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# `router.afterEach(hook)`
2+
3+
Set the global after hook, which will be called every time when a route transition successfully **enters the activation phase**.
4+
5+
Note this hook being called only means the transition has been validated, i.e. all `canDeactivate` and `canActivate` hooks have successfully resolved and the browser URL has been updated. It does not guarantee that all `activate` hooks have been resolved.
6+
7+
You can only have one global after hook at a time; however you can implement your own middleware system inside this hook.
8+
9+
### Arguments
10+
11+
- `hook {Function}`
12+
13+
The hook function receives a single argument which is a [Transition Object](../pipeline/hooks.html#transition-object), but you can only access its `to` and `from` properties, which are route objects. You **cannot** call transition methods in the global after hook.
14+
15+
### Example
16+
17+
``` js
18+
router.afterEach(function (transition) {
19+
console.log('Successfully navigated to: ' + transition.to.path)
20+
})
21+
```

docs/api/on.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Add a single root-level route configuration. Internally, `router.map()` simply c
55
### Arguments
66

77
- `path: String` - see [Route Matching](../route.md#route-matching)
8-
- `config: Object` - see [Route Config Object](map.html#route-config-object).
8+
- `config: Object` - see [Route Config Object](map.md#route-config-object).
99

1010
### Example
1111

docs/pipeline/activate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Called on an incoming component during the activation phase when it is created a
44

55
### Arguments
66

7-
- [`transition {Transition}`](hooks.html#transition-object)
7+
- [`transition {Transition}`](hooks.md#transition-object)
88

99
Call `transition.next()` to resolve the hook. Note calling `transition.abort()` here will not take the app back to the previous route because the transition has already been validated.
1010

docs/pipeline/can-activate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Called on an incoming component during the validation phase.
44

55
### Arguments
66

7-
- [`transition {Transition}`](hooks.html#transition-object)
7+
- [`transition {Transition}`](hooks.md#transition-object)
88

99
Call `transition.next()` to resolve the hook. Calling `transition.abort()` will invalidate and cancel the transition.
1010

docs/pipeline/can-deactivate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Called on a leaving component during the validation phase.
44

55
### Arguments
66

7-
- [`transition {Transition}`](hooks.html#transition-object)
7+
- [`transition {Transition}`](hooks.md#transition-object)
88

99
Call `transition.next()` to resolve the hook. Calling `transition.abort()` will invalidate and cancel the transition.
1010

docs/pipeline/can-reuse.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This route options can either be a plain Boolean value, or a function that synch
66

77
### Arguments
88

9-
- [`transition {Transition}`](hooks.html#transition-object)
9+
- [`transition {Transition}`](hooks.md#transition-object)
1010

1111
You can only access `transition.to` and `transition.from` in a `canReuse` hook.
1212

docs/pipeline/data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Called on an incoming component during the activation phase, after the `activate
44

55
### Arguments
66

7-
- [`transition {Transition}`](hooks.html#transition-object)
7+
- [`transition {Transition}`](hooks.md#transition-object)
88

99
Calling `transition.next(data)` will set each property in `data` on the component. For example, with `{ a: 1, b: 2 }`, the router will call `component.$set('a', 1)` and `component.$set('b', 2)`.
1010

docs/pipeline/deactivate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Called on a leaving component the activation phase when it is about to be deacti
44

55
### Arguments
66

7-
- [`transition {Transition}`](hooks.html#transition-object)
7+
- [`transition {Transition}`](hooks.md#transition-object)
88

99
Call `transition.next()` to resolve the hook. Note calling `transition.abort()` here will not take the app back to the previous route because the transition has already been validated.
1010

docs/pipeline/hooks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Each transition hook will receive a `transition` object as the only argument. Th
3333

3434
- **transition.from**
3535

36-
A [route object](../route.html) representing the route we are transitioning from.
36+
A [route object](../route.md) representing the route we are transitioning from.
3737

3838
- **transition.to**
3939

@@ -90,7 +90,7 @@ route: {
9090
}
9191
```
9292

93-
We are asynchronously fetching data in the `activate` hook here just for the sake of an example; Note that we also have the [`data` hook](data.html) which is in general more appropriate for this purpose.
93+
We are asynchronously fetching data in the `activate` hook here just for the sake of an example; Note that we also have the [`data` hook](data.md) which is in general more appropriate for this purpose.
9494

9595
**TIP:** if you are using ES6 you can use argument destructuring to make your hooks cleaner:
9696

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"e2e-sauce": "nightwatch -c build/nightwatch.sauce.json -e chrome,firefox,ie10,ie11",
1414
"e2e-local": "bash ./build/e2e.sh",
1515
"release": "bash ./build/release.sh",
16-
"docs": "bash ./build/update-docs.sh",
16+
"docs": "cd docs && gitbook serve",
17+
"deploy-docs": "bash ./build/update-docs.sh",
1718
"test": "npm run lint && npm run unit && npm run e2e-local"
1819
},
1920
"repository": {

0 commit comments

Comments
 (0)