當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。