本文整理匯總了TypeScript中rxjs/operators.every函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript every函數的具體用法?TypeScript every怎麽用?TypeScript every使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了every函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: runCanDeactivateChecks
function runCanDeactivateChecks(
checks: CanDeactivate[], futureRSS: RouterStateSnapshot, currRSS: RouterStateSnapshot,
moduleInjector: Injector): Observable<boolean> {
return from(checks).pipe(
mergeMap(
(check: CanDeactivate) =>
runCanDeactivate(check.component, check.route, currRSS, futureRSS, moduleInjector)),
every((result: boolean) => result === true));
}
示例2: every2
every2() {
// emit 5 values
const allEvens = of(2, 4, 6, 8, 10);
const example = allEvens.pipe(
// is every value even?
every(val => val % 2 === 0)
);
// output: true
const subscribe = example.subscribe(val => console.log(val));
}
示例3: every1
every1() {
// emit 5 values
const source = of(1, 2, 3, 4, 5);
const example = source.pipe(
// is every value even?
every(val => val % 2 === 0)
);
// output: false
const subscribe = example.subscribe(val => console.log(val));
}
示例4: runCanActivateChecks
function runCanActivateChecks(
futureSnapshot: RouterStateSnapshot, checks: CanActivate[], moduleInjector: Injector,
forwardEvent?: (evt: Event) => void): Observable<boolean> {
return from(checks).pipe(
concatMap((check: CanActivate) => andObservables(from([
fireChildActivationStart(check.route.parent, forwardEvent),
fireActivationStart(check.route, forwardEvent),
runCanActivateChild(futureSnapshot, check.path, moduleInjector),
runCanActivate(futureSnapshot, check.route, moduleInjector)
]))),
every((result: boolean) => result === true));
}
示例5: runCanDeactivate
function runCanDeactivate(
component: Object | null, currARS: ActivatedRouteSnapshot, currRSS: RouterStateSnapshot,
futureRSS: RouterStateSnapshot, moduleInjector: Injector): Observable<boolean> {
const canDeactivate = currARS && currARS.routeConfig ? currARS.routeConfig.canDeactivate : null;
if (!canDeactivate || canDeactivate.length === 0) return of (true);
const canDeactivate$ = from(canDeactivate).pipe(mergeMap((c: any) => {
const guard = getToken(c, currARS, moduleInjector);
let observable: Observable<boolean>;
if (guard.canDeactivate) {
observable = wrapIntoObservable(guard.canDeactivate(component, currARS, currRSS, futureRSS));
} else {
observable = wrapIntoObservable(guard(component, currARS, currRSS, futureRSS));
}
return observable.pipe(first());
}));
return canDeactivate$.pipe(every((result: any) => result === true));
}
示例6: it
it('should support index and its type', () => {
const a = of(1, 2, 3).pipe(every((val, index: number) => val < 3)); // $ExpectType Observable<boolean>
});