本文整理汇总了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>
});