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