Skip to content

Commit 08bdc96

Browse files
committed
docs for hook merging
1 parent c134290 commit 08bdc96

File tree

7 files changed

+23
-8
lines changed

7 files changed

+23
-8
lines changed

docs/en/pipeline/activate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Called on an incoming component during the activation phase when it is created a
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

11-
### Return Value
11+
### Expected Return Value
1212

1313
- Optionally return a Promise.
1414
- `resolve` -> `transition.next()`

docs/en/pipeline/can-activate.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ Called on an incoming component during the validation phase.
88

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

11-
### Return Value
11+
### Expected Return Value
1212

1313
- Optionally return a Promise:
1414

1515
- `resolve(true)` -> `transition.next()`
1616
- `resolve(false)` -> `transition.abort()`
1717
- `reject(reason)` -> `transition.abort(reason)`
1818

19+
1920
- Optionally return a Boolean:
2021

2122
- `true` -> `transition.next()`

docs/en/pipeline/can-deactivate.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ Called on a leaving component during the validation phase.
88

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

11-
### Return Value
11+
### Expected Return Value
1212

1313
- Optionally return a Promise:
1414

1515
- `resolve(true)` -> `transition.next()`
1616
- `resolve(false)` -> `transition.abort()`
1717
- `reject(reason)` -> `transition.abort(reason)`
1818

19+
1920
- Optionally return a Boolean:
2021

2122
- `true` -> `transition.next()`

docs/en/pipeline/can-reuse.md

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

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

13-
### Return Value
13+
### Expected Return Value
1414

1515
- Must return a Boolean. Falsy values are treated as `false`.
1616

docs/en/pipeline/data.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ Called on an incoming component during the activation phase, after the `activate
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

11-
### Return Value
11+
### Expected Return Value
1212

1313
- optionally return a Promise.
1414
- `resolve(data)` -> `transition.next(data)`
1515
- `reject(reason)` -> `transition.abort(reason)`
1616

17-
- or, return an Object containing Promises. See [Promise sugar](#promise-sugar) below.
17+
18+
- **OR:** return an Object containing Promises. See [Promise sugar](#promise-sugar) below.
1819

1920
### Details
2021

docs/en/pipeline/deactivate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Called on a leaving component the activation phase when it is about to be deacti
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

11-
### Return Value
11+
### Expected Return Value
1212

1313
- Optionally return a Promise.
1414
- `resolve` -> `transition.next()`

docs/en/pipeline/hooks.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,16 @@ route: {
127127
}
128128
```
129129

130-
Check out the [advanced example](https://github.com/vuejs/vue-router/tree/dev/example/advanced) in the vue-router repo.
130+
For a full example of transition hooks in action, check out the [advanced example](https://github.com/vuejs/vue-router/tree/dev/example/advanced) in the vue-router repo.
131+
132+
### Hook Merging
133+
134+
Similar to component lifecycle hooks, the following route lifecycle hooks:
135+
136+
- `data`
137+
- `activate`
138+
- `deactivate`
139+
140+
...are merged during class extension or mixins. For example, if your component defines a route `data` hook, and uses a mixin that also provides a route `data` hook, both hooks will get called (mixin hooks called first) and the resolved data from all hooks will be merged together.
141+
142+
Note that validation hooks like `canActivate`, `canDeactivate` and `canReuse` are always overwritten by the newer value.

0 commit comments

Comments
 (0)