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


TypeScript rxjs.zip函數代碼示例

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


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

示例1: updateUserSettings

    updateUserSettings(username: string, name: string, email: string, profilePicture?: FormData): Observable<any> {
        const body = { name, email };

        if (profilePicture) {
            return zip(
                this.http.put(`${environment.URL}/user/${username}`, body),
                this.http.post(`${environment.URL}/user/${username}`, profilePicture),
                (r1, r2) => r2
            );
        } else {
            return zip(
                this.http.put(`${environment.URL}/user/${username}`, body)
            );
        }
    }
開發者ID:pastorsj,項目名稱:bannablog,代碼行數:15,代碼來源:author.service.ts

示例2: getWords

 private getWords(titles: string[], locale: Locale, source: SearchResultsSource, progressObserver?: Observer<number>) {
   let progress = 0;
   let rateLimitingDelay = 0;
   const getWords = titles.map(title => {
     const getWord = of(null).pipe(
       delay(rateLimitingDelay), // Adding delay for rate limiting to prevent HTTP error 429 from backend.
       mergeMap(_ => this.getWordByLoadingSearchResults(title, locale, source)),
       finalize(() => {
         if (progressObserver) {
           progress++;
           progressObserver.next(progress);
         }
       })
     );
     rateLimitingDelay += 1000;
     return getWord;
   });
   return zip(...getWords).pipe(
     finalize(() => {
       if (progressObserver) {
         progressObserver.complete();
       }
     })
   );
 }
開發者ID:tobihagemann,項目名稱:shitishot,代碼行數:25,代碼來源:game.service.ts

示例3: it

it('should support mixed observables and promises', () => {
  const a = Promise.resolve(1); // $ExpectType Promise<number>
  const b = of('foo'); // $ExpectType Observable<string>
  const c = of(true); // $ExpectType Observable<boolean>
  const d = of(['bar']); // $ExpectType Observable<string[]>
  const o1 = zip(a, b, c, d); // $ExpectType Observable<[number, string, boolean, string[]]>
});
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:7,代碼來源:zip-spec.ts

示例4: zip2

 zip2() {
   // emit every 1s
   const source = interval(1000);
   // when one observable completes no more values will be emitted
   const example = zip(source, source.pipe(take(2)));
   // output: [0,0]...[1,1]
   const subscribe = example.subscribe(val => console.log(val));
 }
開發者ID:zwvista,項目名稱:SampleMisc,代碼行數:8,代碼來源:combining.service.ts

示例5: Image

                    (() => {
                        const alertImg = new Image();

                        alertImg.src = ServerMapTheme.general.common.funcServerMapImagePath(ServerMapTheme.general.common.icon.error);
                        return zip(
                            serviceTypeImgLoadEvent$.pipe(pluck('target')),
                            fromEvent(alertImg, 'load').pipe(pluck('target'))
                        );
                    })(),
開發者ID:young891221,項目名稱:pinpoint,代碼行數:9,代碼來源:server-map-diagram-with-visjs.class.ts

示例6: sample2

 sample2() {
   const source = zip(
     // emit 'Joe', 'Frank' and 'Bob' in sequence
     from(['Joe', 'Frank', 'Bob']),
     // emit value every 2s
     interval(2000)
   );
   // sample last emitted value from source every 2.5s
   const example = source.pipe(sample(interval(2500)));
   // output: ["Joe", 0]...["Frank", 1]...........
   const subscribe = example.subscribe(val => console.log(val));
 }
開發者ID:zwvista,項目名稱:SampleMisc,代碼行數:12,代碼來源:filtering.service.ts

示例7: switchMap

        switchMap(info => {
            const resolveBaseCommitID = resolveDiffRev({
                repoPath: info.baseRepoPath,
                differentialID: info.differentialID,
                diffID: (info.leftDiffID || info.diffID)!,
                leftDiffID: info.leftDiffID,
                useDiffForBase: Boolean(info.leftDiffID), // if ?vs and base is not `on` i.e. the initial commit)
                useBaseForDiff: false,
                filePath: info.baseFilePath || info.filePath,
                isBase: true,
            }).pipe(
                map(({ commitID, stagingRepoPath }) => ({
                    baseCommitID: commitID,
                    baseRepoPath: stagingRepoPath || info.baseRepoPath,
                })),
                catchError(err => {
                    throw err
                })
            )

            const resolveHeadCommitID = resolveDiffRev({
                repoPath: info.headRepoPath,
                differentialID: info.differentialID,
                diffID: info.diffID!,
                leftDiffID: info.leftDiffID,
                useDiffForBase: false,
                useBaseForDiff: false,
                filePath: info.filePath,
                isBase: false,
            }).pipe(
                map(({ commitID, stagingRepoPath }) => ({
                    headCommitID: commitID,
                    headRepoPath: stagingRepoPath || info.headRepoPath,
                })),
                catchError(err => {
                    throw err
                })
            )

            return zip(resolveBaseCommitID, resolveHeadCommitID).pipe(
                map(([{ baseCommitID, baseRepoPath }, { headCommitID, headRepoPath }]) => ({
                    baseCommitID,
                    headCommitID,
                    ...info,
                    baseRepoPath,
                    headRepoPath,
                }))
            )
        }),
開發者ID:JoYiRis,項目名稱:sourcegraph,代碼行數:49,代碼來源:file_info.ts

示例8: zip1

 zip1() {
   const sourceOne = of('Hello');
   const sourceTwo = of('World!');
   const sourceThree = of('Goodbye');
   const sourceFour = of('World!');
   // wait until all observables have emitted a value then emit all as an array
   const example = zip(
     sourceOne,
     sourceTwo.pipe(delay(1000)),
     sourceThree.pipe(delay(2000)),
     sourceFour.pipe(delay(3000))
   );
   // output: ["Hello", "World!", "Goodbye", "World!"]
   const subscribe = example.subscribe(val => console.log(val));
 }
開發者ID:zwvista,項目名稱:SampleMisc,代碼行數:15,代碼來源:combining.service.ts

示例9: stateFn

export function stateFn(initState: AppState, actions: Observable<Action>): Observable<AppState> {
    const combine = s => ({
        hero: s[0],
        currentTask: s[1],
        hasActiveTask: s[2],
        activeTaskMode: s[3],
    });
    const appStateObs: Observable<AppState> = 
        zip(
            hero(initState.hero, actions),
            currentTask(initState.currentTask, actions),
            hasActiveTask(initState.hasActiveTask, actions),
            activeTaskMode(initState.activeTaskMode, actions),
        ).pipe(
            map(combine),
        );
    return wrapIntoBehavior(initState, appStateObs);
}
開發者ID:scunningham777,項目名稱:SelecQuest,代碼行數:18,代碼來源:state-store.ts


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