Last active
February 25, 2021 01:21
-
-
Save andrewarosario/ee2520414959d4ec7aa418fff3bff66f to your computer and use it in GitHub Desktop.
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
export const USER_DETAIL = new InjectionToken<Observable<User>>( | |
'A stream with current user detail' | |
); | |
export const USER_PROVIDERS: Provider[] = [ | |
{ | |
provide: USER_DETAIL, | |
deps: [ActivatedRoute, UserService], | |
useFactory: userFactory, | |
}, | |
]; | |
export function userFactory( | |
route: ActivatedRoute, | |
userService: UserService | |
): Observable<User> { | |
return route.paramMap.pipe( | |
switchMap((params) => { | |
const id = params.get('orgId'); | |
return userService.getById$(id); | |
}) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment