feat(router): guards and data resolvers can now return promises
This commit is contained in:
@ -242,7 +242,8 @@ export type RouterConfig = Route[];
|
||||
* - `outlet` is the name of the outlet the component should be placed into.
|
||||
* - `canActivate` is an array of DI tokens used to look up CanActivate handlers. See {@link
|
||||
* CanActivate} for more info.
|
||||
* - `canActivateChild` is an array of DI tokens used to look up CanActivateChild handlers. See {@link
|
||||
* - `canActivateChild` is an array of DI tokens used to look up CanActivateChild handlers. See
|
||||
* {@link
|
||||
* CanActivateChild} for more info.
|
||||
* - `canDeactivate` is an array of DI tokens used to look up CanDeactivate handlers. See {@link
|
||||
* CanDeactivate} for more info.
|
||||
|
@ -66,7 +66,8 @@ export interface CanActivate {
|
||||
* class CanActivateTeam implements CanActivate {
|
||||
* constructor(private permissions: Permissions, private currentUser: UserToken) {}
|
||||
*
|
||||
* canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot):Observable<boolean> {
|
||||
* canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot):Observable<boolean>
|
||||
* {
|
||||
* return this.permissions.canActivate(this.currentUser, this.route.params.id);
|
||||
* }
|
||||
* }
|
||||
|
@ -12,6 +12,7 @@ import 'rxjs/add/operator/mergeAll';
|
||||
import 'rxjs/add/operator/reduce';
|
||||
import 'rxjs/add/operator/every';
|
||||
import 'rxjs/add/observable/from';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import 'rxjs/add/observable/forkJoin';
|
||||
import 'rxjs/add/observable/of';
|
||||
|
||||
@ -596,6 +597,8 @@ class PreActivation {
|
||||
function wrapIntoObservable<T>(value: T | Observable<T>): Observable<T> {
|
||||
if (value instanceof Observable) {
|
||||
return value;
|
||||
} else if (value instanceof Promise) {
|
||||
return Observable.fromPromise(value);
|
||||
} else {
|
||||
return Observable.of(value);
|
||||
}
|
||||
|
Reference in New Issue
Block a user