當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript operators.skipWhile函數代碼示例

本文整理匯總了TypeScript中rxjs/operators.skipWhile函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript skipWhile函數的具體用法?TypeScript skipWhile怎麽用?TypeScript skipWhile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了skipWhile函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it('should handle predicate that throws', () => {
    const source = hot('--a--b-^-c--d--e--f--g--h--|');
    const sourceSubs =        '^       !';
    const expected =          '--------#';

    const predicate = function (v: string) {
      if (v === 'e') {
        throw new Error('nom d\'une pipe !');
      }

      return v !== 'f';
    };

    expectObservable(source.pipe(skipWhile(predicate))).toBe(expected, undefined, new Error('nom d\'une pipe !'));
    expectSubscriptions(source.subscriptions).toBe(sourceSubs);
  });
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:16,代碼來源:skipWhile-spec.ts

示例2: withLatestFrom

function waitForLoaded<T>(query: DatabaseQuery, action$: Observable<SnapshotAction<T>[]>) {
  const loaded$ = loadedData<T>(query);
  return loaded$
    .pipe(
      withLatestFrom(action$),
      // Get the latest values from the "loaded" and "child" datasets
      // We can use both datasets to form an array of the latest values.
      map(([loaded, actions]) => {
        // Store the last key in the data set
        let lastKeyToLoad = loaded.lastKeyToLoad;
        // Store all child keys loaded at this point
        const loadedKeys = actions.map(snap => snap.key);
        return { actions, lastKeyToLoad, loadedKeys }
      }),
      // This is the magical part, only emit when the last load key
      // in the dataset has been loaded by a child event. At this point
      // we can assume the dataset is "whole".
      skipWhile(meta => meta.loadedKeys.indexOf(meta.lastKeyToLoad) === -1),
      // Pluck off the meta data because the user only cares
      // to iterate through the snapshots
      map(meta => meta.actions)
    );
}
開發者ID:PaulD11,項目名稱:angularfire2,代碼行數:23,代碼來源:audit-trail.ts

示例3: higherOrder

export function skipWhile<T>(this: Observable<T>, predicate: (value: T, index: number) => boolean): Observable<T> {
  return higherOrder(predicate)(this);
}
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:3,代碼來源:skipWhile.ts

示例4: it

it('should support a predicate with an index', () => {
  const o = of('foo', 'bar', 'baz').pipe(skipWhile((value, index) => index < 3)); // $ExpectType Observable<string>
});
開發者ID:jaychsu,項目名稱:RxJS,代碼行數:3,代碼來源:skipWhile-spec.ts


注:本文中的rxjs/operators.skipWhile函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。