本文整理汇总了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;未经允许,请勿转载。 |
请发表评论