-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(Guards): Re-implement guards feature to use services (#81)
Before we used `provideGuard` to quickly create guard factory functions. In order to play better with the offline compiler, this changes guards to instead use traditional services. BREAKING CHANGE: Before: ```ts const auth = provideGuard(function(http: Http) { return function(route: Route, params: any, isTerminal: boolean): Observable<boolean> { return http.get('/auth') .map(() => true) .catch(() => Observable.of(false)); }; }, [ Http ]); ``` After: ```ts @Injectable() export class AuthGuard implements Guard { constructor(private http: Http) { } protectRoute({ route, params, isTerminal }: TraversalCandidate): Observable<boolean> { return this.http.get('/auth') .map(() => true) .catch(() => Observable.of(false)); } } ```
- Loading branch information
1 parent
2d51638
commit 145b671
Showing
4 changed files
with
96 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters