当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript operators.every函数代码示例

本文整理汇总了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));
}
开发者ID:KaneFreeman,项目名称:angular,代码行数:9,代码来源:check_guards.ts

示例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));
 }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:10,代码来源:conditional.service.ts

示例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));
 }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:10,代码来源:conditional.service.ts

示例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));
}
开发者ID:KaneFreeman,项目名称:angular,代码行数:12,代码来源:check_guards.ts

示例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));
}
开发者ID:KaneFreeman,项目名称:angular,代码行数:17,代码来源:check_guards.ts

示例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>
});
开发者ID:jaychsu,项目名称:RxJS,代码行数:3,代码来源:every-spec.ts


注:本文中的rxjs/operators.every函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。