当前位置: 首页>>代码示例>>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;未经允许,请勿转载。