Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 26x 26x 26x 26x 26x 3x 3x 3x 3x 3x | import { inject } from '@angular/core';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Store, select } from '@ngrx/store';
import { Observable } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { getUserCount, loadUsers } from '../store/users';
/**
* Fetch users for user management page
*/
export function fetchUsersGuard(route: ActivatedRouteSnapshot): boolean | Observable<boolean> {
const store = inject(Store);
return store.pipe(
select(getUserCount),
tap(count => {
if (count <= 1 || !route.data.onlyInitialUsers) {
store.dispatch(loadUsers());
}
}),
map(() => true)
);
}
|