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


TypeScript rxjs.pipe函数代码示例

本文整理汇总了TypeScript中rxjs.pipe函数的典型用法代码示例。如果您正苦于以下问题:TypeScript pipe函数的具体用法?TypeScript pipe怎么用?TypeScript pipe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pipe函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

it('should return Observable<{}> when T cannot be inferred', () => {
  const customOperator = <T>() => (a: Observable<T>) => a;

  // type can't be possibly be inferred here, so it's {} instead of T.
  const staticPipe = pipe(customOperator());
  const o = of('foo').pipe(staticPipe); // $ExpectType Observable<{}>
});
开发者ID:jaychsu,项目名称:RxJS,代码行数:7,代码来源:pipe-spec.ts

示例2: it

  it('should return a noop if not passed a function', () => {
    const c = pipe();

    expect(c('whatever')).to.equal('whatever');
    const someObj = {};
    expect(c(someObj)).to.equal(someObj);
  });
开发者ID:DallanQ,项目名称:rxjs,代码行数:7,代码来源:pipe-spec.ts

示例3: validateFormLabels

export function validateFormLabels(jobSpec: JobSpec): FormError[] {
  const labels = (jobSpec.job.labels || []).map(([k]) => k);
  const message = i18nMark("Cannot have multiple labels with the same key.");

  return pipe(
    allUniq(_ => "job.labels", [labels], message),
    isUniqIn(labels)(i => `job.labels.${i}`, labels, message)
  )([]);
}
开发者ID:dcos,项目名称:dcos-ui,代码行数:9,代码来源:MetronomeJobValidators.ts

示例4: backoff

function backoff(maxTries, ms) {
 return pipe(
   retryWhen(attempts => zip(range(1, maxTries), attempts)
     .pipe(
       map(([i]) => i * i),
       mergeMap(i =>  timer(i * ms))
     )
   )
 );
}
开发者ID:BobChao87,项目名称:angular,代码行数:10,代码来源:backoff.ts

示例5: backoff

function backoff(maxTries, ms) {
 return pipe(
   retryWhen(attempts => range(1, maxTries)
     .pipe(
       zip(attempts, (i) => i),
       map(i => i * i),
       mergeMap(i =>  timer(i * ms))
     )
   )
 );
}
开发者ID:DallanQ,项目名称:rxjs,代码行数:11,代码来源:backoff.ts

示例6: create

    async create(fileChanges: VcsFileChange[]): Promise<VcsItemCreateResult<NoteVcsItemComponent>> {
        const usedFileChanges: VcsFileChange[] = [];
        const refs: VcsItemRef<NoteVcsItemComponent>[] = [];

        // Get notes first.
        const notes = await toPromise(this.store.pipe(
            select(state => state.note.collection.notes),
            pipe(take(1)),
        ));

        for (const note of notes) {
            let index: number;
            const willUseFileChanges: VcsFileChange[] = [];

            // Note file
            index = fileChanges.findIndex(change => change.absoluteFilePath === note.filePath);
            if (index !== -1) {
                willUseFileChanges.push(fileChanges[index]);
            }

            // Note content file
            index = fileChanges.findIndex(change => change.absoluteFilePath === note.contentFilePath);
            if (index !== -1) {
                willUseFileChanges.push(fileChanges[index]);
            }

            if (willUseFileChanges.length > 0) {
                const config: VcsItemConfig = {
                    title: note.title,
                    fileChanges: willUseFileChanges,
                };

                const ref = new VcsItemRef<NoteVcsItemComponent>(config);
                ref.component = NoteVcsItemComponent;

                usedFileChanges.push(...willUseFileChanges);
                refs.push(ref);
            }
        }

        return { refs, usedFileChanges };
    }
开发者ID:suiruiw,项目名称:geeks-diary,代码行数:42,代码来源:note-vcs-item-factory.ts


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