Skip to content

Commit

Permalink
Updated shell-app.service.ts > SHELL_AUTH_TOKEN to use functional rou…
Browse files Browse the repository at this point in the history
…te guards instead of class based one
  • Loading branch information
swapnil-verma-gl committed Jun 26, 2024
1 parent 4f4ae56 commit bef14dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion lib/core/shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ I order to attach routes to appShell, `withRoutes(routes: Routes | AppShellRoute

Passed routes are going to be attached to [shell main route](./src/lib/shell.routes.ts)

If you would like to provide custom app guard, you can provide your own using [SHELL_AUTH_TOKEN](./src/lib/shell.routes.ts)
If you would like to provide custom app guard, you can provide your own using [SHELL_AUTH_TOKEN](./src/lib/shell.routes.ts). Keep in mind that
the custom app guard must be a functional route guard, instead of a class based one.

## Shell Service

Expand Down
16 changes: 8 additions & 8 deletions lib/core/shell/src/lib/services/shell-app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
*/

import { InjectionToken } from '@angular/core';
import { CanActivate, CanActivateChild } from '@angular/router';
import { CanActivateFn, CanActivateChildFn } from '@angular/router';
import { Observable } from 'rxjs';

export interface ShellPreferencesService {
set(preferenceKey: string, value: any): void;
get(preferenceKey: string, defaultValue: string): string;
set(preferenceKey: string, value: any): void;
get(preferenceKey: string, defaultValue: string): string;
}

export interface ShellAppService {
pageHeading$: Observable<string>;
hideSidenavConditions: string[];
minimizeSidenavConditions: string[];
preferencesService: ShellPreferencesService;
pageHeading$: Observable<string>;
hideSidenavConditions: string[];
minimizeSidenavConditions: string[];
preferencesService: ShellPreferencesService;
}

export const SHELL_APP_SERVICE = new InjectionToken<ShellAppService>('SHELL_APP_SERVICE');

export const SHELL_AUTH_TOKEN = new InjectionToken<CanActivate & CanActivateChild>('SHELL_AUTH_TOKEN');
export const SHELL_AUTH_TOKEN = new InjectionToken<CanActivateFn & CanActivateChildFn>('SHELL_AUTH_TOKEN');
export const SHELL_NAVBAR_MIN_WIDTH = new InjectionToken<number>('SHELL_NAVBAR_MIN_WIDTH');
export const SHELL_NAVBAR_MAX_WIDTH = new InjectionToken<number>('SHELL_NAVBAR_MAX_WIDTH');

0 comments on commit bef14dd

Please sign in to comment.