Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

doc(routing): event.allowLeave() is on the PreLeave event since 0.4.21 #1469

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/routing/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,29 @@
* EditRecipe(RouteProvider routeProvider) {
* RouteHandle route = routeProvider.route.newHandle();
* _loadRecipe(route);
* route.onLeave.listen((RouteEvent event) {
* route.onPreLeave.listen((RouteEvent event) {
* event.allowLeave(_checkIfOkToLeave());
* });
* }
*
* /// Check if the editor has unsaved contents and if necessary ask
* /// the user if OK to leave this page.
* Future<bool> _checkIfOkToLeave() {/* ... */}
* Future<bool> _checkIfOkToLeave() => /* ... */;
*
* detach() {
* route.discard();
* }
* }
*
* [Route.onLeave] event is triggered when the browser is routed from an
* [Route.onPreLeave] event is triggered when the browser is routed from an
* active route to a different route. The active route can delay and
* potentially veto the navigation by passing a [Future<bool>] to
* [RouteEvent.allowLeave].
* [RoutePreLeaveEvent.allowLeave].
*
* Notice that we create a [RouteHandle] for our route. [RouteHandle] are
* a convenient wrapper around [Route] that makes unsubscribing route events
* easier. For example, notice that we didn't need to manually call
* [StreamSubscription.cancel] for subscription to [Route.onLeave]. Calling
* [StreamSubscription.cancel] for subscription to [Route.onPreLeave]. Calling
* [RouteHandle.discard] unsubscribes all listeners created for the handle.
*
* ## Hierarchical Routes
Expand Down
4 changes: 2 additions & 2 deletions lib/routing/ng_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class NgView implements DetachAware, RouteProvider {
* route.onEnter.listen((RouteEvent e) {
* // Do something when the route is activated.
* });
* route.onLeave.listen((RouteEvent e) {
* route.onPreLeave.listen((RouteEvent e) {
* // Do something when the route is de-activated.
* e.allowLeave(allDataSaved());
* });
Expand All @@ -193,7 +193,7 @@ class NgView implements DetachAware, RouteProvider {
* }
* }
*
* If user component is used outside of ng-view directive then
* If user component is used outside of `ng-view` directive then
* injected [RouteProvider] will be null.
*/
abstract class RouteProvider {
Expand Down