feat(router): add CanDeactivate
This commit is contained in:
parent
e5b87e55da
commit
deba804671
|
@ -4,3 +4,8 @@ export interface OnActivate {
|
|||
routerOnActivate(curr: RouteSegment, prev?: RouteSegment, currTree?: Tree<RouteSegment>,
|
||||
prevTree?: Tree<RouteSegment>): void;
|
||||
}
|
||||
|
||||
export interface CanDeactivate {
|
||||
routerCanDeactivate(currTree?: Tree<RouteSegment>,
|
||||
futureTree?: Tree<RouteSegment>): Promise<boolean>;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import './interfaces.dart';
|
||||
bool hasLifecycleHook(String name, Object obj) {
|
||||
if (name == "routerOnActivate") return obj is OnActivate;
|
||||
if (name == "routerCanDeactivate") return obj is CanDeactivate;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {Type} from 'angular2/src/facade/lang';
|
||||
import {Type, isBlank} from 'angular2/src/facade/lang';
|
||||
|
||||
export function hasLifecycleHook(name: string, obj: Object): boolean {
|
||||
if (isBlank(obj)) return false;
|
||||
let type = obj.constructor;
|
||||
if (!(type instanceof Type)) return false;
|
||||
return name in(<any>type).prototype;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {Type, isPresent} from 'angular2/src/facade/lang';
|
||||
import {Type, isBlank} from 'angular2/src/facade/lang';
|
||||
import {RouteLifecycleHook, CanActivate} from './lifecycle_annotations_impl';
|
||||
import {reflector} from 'angular2/src/core/reflection/reflection';
|
||||
|
||||
|
|
Loading…
Reference in New Issue