本文整理汇总了TypeScript中rxjs/operators.expand函数的典型用法代码示例。如果您正苦于以下问题:TypeScript expand函数的具体用法?TypeScript expand怎么用?TypeScript expand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了expand函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: expand1
expand1() {
// emit 2
const source = of(2);
const example = source.pipe(
// recursively call supplied function
expand(val => {
// 2,3,4,5,6
console.log(`Passed value: ${val}`);
// 3,4,5,6
return of(1 + val);
}),
// call 5 times
take(5)
);
/*
"RESULT: 2"
"Passed value: 2"
"RESULT: 3"
"Passed value: 3"
"RESULT: 4"
"Passed value: 4"
"RESULT: 5"
"Passed value: 5"
"RESULT: 6"
"Passed value: 6"
*/
// output: 2,3,4,5,6
const subscribe = example.subscribe(val => console.log(`RESULT: ${val}`));
}
开发者ID:zwvista,项目名称:SampleMisc,代码行数:29,代码来源:transforming.service.ts
示例2: higherOrder
export function expand<T, R>(this: Observable<T>, project: (value: T, index: number) => ObservableInput<R>,
concurrent: number = Number.POSITIVE_INFINITY,
scheduler: SchedulerLike = undefined): Observable<R> {
concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent;
return higherOrder(project, concurrent, scheduler)(this);
}
开发者ID:DallanQ,项目名称:rxjs,代码行数:7,代码来源:expand.ts
示例3: expand
observable1 = expandZone1.run(() => {
return observable1.pipe(
expand((val: any) => {
expect(Zone.current.name).toEqual(expandZone1.name);
return of(1 + val);
}),
take(2));
});
开发者ID:angular,项目名称:zone.js,代码行数:8,代码来源:rxjs.Observable.merge.spec.ts
示例4: pollBuildProgress
private pollBuildProgress(locatorType: string, locator: string, minRevision: number): Observable<ProgressStatus> {
return this.getBuildProgress(locatorType, locator, minRevision).pipe(
expand(buildDto => {
if (buildDto != null) {
locatorType = 'id';
locator = buildDto.id;
minRevision = buildDto.revision + 1;
}
return this.getBuildProgress(locatorType, locator, minRevision);
}),
filter(buildDto => buildDto != null),
map(buildDto => buildDto as BuildDto),
takeWhileInclusive(buildDto => buildDto.state === BuildStates.Pending || buildDto.state === BuildStates.Active)
);
}
开发者ID:sillsdev,项目名称:machine,代码行数:15,代码来源:web-api-client.ts
示例5: it
it('should infer correctly with a different type as the source', () => {
const o = of(1, 2, 3).pipe(expand(value => of('foo'))); // $ExpectType Observable<string>
const p = of(1, 2, 3).pipe(expand(value => ['foo'])); // $ExpectType Observable<string>
const q = of(1, 2, 3).pipe(expand(value => Promise.resolve('foo'))); // $ExpectType Observable<string>
});
开发者ID:jaychsu,项目名称:RxJS,代码行数:5,代码来源:expand-spec.ts
注:本文中的rxjs/operators.expand函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论