本文整理汇总了TypeScript中rxjs.combineLatest函数的典型用法代码示例。如果您正苦于以下问题:TypeScript combineLatest函数的具体用法?TypeScript combineLatest怎么用?TypeScript combineLatest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了combineLatest函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: bindTranscript
bindTranscript(records: any[]): Observable<LiftedData> {
const crosslistedRecords = combineLatest(
records.filter(record => record.quality).map(record =>
this.institution
.course(record.course)
.data()
.pipe(
map(data => [record.course, ...(data.crosslists || [])] as string[])
)
)
);
return combineLatest(
this.data().pipe(
map(function lift(program: ProgramData): LiftedData {
return {
requirements: program.requirements
? program.requirements.map(requirement => lift(requirement))
: null,
program,
progress: {} as ProgressData
} as LiftedData;
})
),
records.length == 0 ? of([]) : crosslistedRecords
).pipe(
map(([lifted, crosslistedRecords]) =>
resolve(lifted, crosslistedRecords.slice())
)
);
}
开发者ID:kevmo314,项目名称:canigraduate.uchicago.edu,代码行数:30,代码来源:program.ts
示例2: type
type('should support arrays of observables', () => {
/* tslint:disable:no-unused-variable */
let a: Observable<number>[];
let o1: Observable<number[]> = combineLatest(a);
let o2: Observable<number[]> = combineLatest(...a);
let o3: Observable<number> = combineLatest(a, (...x: any[]) => x.length);
/* tslint:enable:no-unused-variable */
});
开发者ID:DallanQ,项目名称:rxjs,代码行数:8,代码来源:combineLatest-spec.ts
示例3: test
test('returns data and admin client observables as a part of the contract', async () => {
const mockAdminClusterClientInstance = { close: jest.fn() };
const mockDataClusterClientInstance = { close: jest.fn() };
MockClusterClient.mockImplementationOnce(
() => mockAdminClusterClientInstance
).mockImplementationOnce(() => mockDataClusterClientInstance);
const setupContract = await elasticsearchService.setup();
const [esConfig, adminClient, dataClient] = await combineLatest(
setupContract.legacy.config$,
setupContract.adminClient$,
setupContract.dataClient$
)
.pipe(first())
.toPromise();
expect(adminClient).toBe(mockAdminClusterClientInstance);
expect(dataClient).toBe(mockDataClusterClientInstance);
expect(MockClusterClient).toHaveBeenCalledTimes(2);
expect(MockClusterClient).toHaveBeenNthCalledWith(
1,
esConfig,
expect.objectContaining({ context: ['elasticsearch', 'admin'] })
);
expect(MockClusterClient).toHaveBeenNthCalledWith(
2,
esConfig,
expect.objectContaining({ context: ['elasticsearch', 'data'] })
);
expect(mockAdminClusterClientInstance.close).not.toHaveBeenCalled();
expect(mockDataClusterClientInstance.close).not.toHaveBeenCalled();
});
开发者ID:elastic,项目名称:kibana,代码行数:35,代码来源:elasticsearch_service.test.ts
示例4: applyInternal
protected applyInternal(node: Element, directive: IDirective<string>, state: INodeState) {
const observable = directive.evaluate(this.dataFlow) as Observable<string> | Observable<string>[];
let subscription;
if (Array.isArray(observable)) {
subscription = combineLatest(observable).subscribe(values => {
const zipped = directive.parameters.map((text, i) => {
let value = values[i];
if ((value === null) || (value === undefined)) {
value = "";
} else if (Array.isArray(value)) {
value = value.join(", ");
}
return text + value;
});
node.nodeValue = zipped.join("");
});
} else {
subscription = observable.subscribe(value => {
if ((value === null) || (value === undefined)) {
value = "";
} else if (Array.isArray(value)) {
value = value.join(", ");
}
node.textContent = value;
});
}
directive.cleanup.add(subscription);
}
开发者ID:milutinovici,项目名称:proactive,代码行数:28,代码来源:text.ts
示例5: switchMap
return switchMap(obs => {
return combineLatest(
...obs.map(o => o.pipe(take(1), startWith(INITIAL_VALUE as INTERIM_VALUES))))
.pipe(
scan(
(acc: INTERIM_VALUES, list: INTERIM_VALUES[]) => {
let isPending = false;
return list.reduce((innerAcc, val, i: number) => {
if (innerAcc !== INITIAL_VALUE) return innerAcc;
// Toggle pending flag if any values haven't been set yet
if (val === INITIAL_VALUE) isPending = true;
// Any other return values are only valid if we haven't yet hit a pending call.
// This guarantees that in the case of a guard at the bottom of the tree that
// returns a redirect, we will wait for the higher priority guard at the top to
// finish before performing the redirect.
if (!isPending) {
// Early return when we hit a `false` value as that should always cancel
// navigation
if (val === false) return val;
if (i === list.length - 1 || val instanceof UrlTree) {
return val;
}
}
return innerAcc;
}, acc);
},
INITIAL_VALUE),
filter(item => item !== INITIAL_VALUE), take(1)) as Observable<boolean|UrlTree>;
});
开发者ID:KaneFreeman,项目名称:angular,代码行数:33,代码来源:prioritized_guard_value.ts
示例6: combineLatest1
combineLatest1() {
// timerOne emits first value at 1s, then once every 4s
const timerOne = timer(1000, 4000);
// timerTwo emits first value at 2s, then once every 4s
const timerTwo = timer(2000, 4000);
// timerThree emits first value at 3s, then once every 4s
const timerThree = timer(3000, 4000);
// when one timer emits, emit the latest values from each timer as an array
const combined = combineLatest(timerOne, timerTwo, timerThree);
const subscribe = combined.subscribe(
([timerValOne, timerValTwo, timerValThree]) => {
/*
Example:
timerOne first tick: 'Timer One Latest: 1, Timer Two Latest:0, Timer Three Latest: 0
timerTwo first tick: 'Timer One Latest: 1, Timer Two Latest:1, Timer Three Latest: 0
timerThree first tick: 'Timer One Latest: 1, Timer Two Latest:1, Timer Three Latest: 1
*/
console.log(
`Timer One Latest: ${timerValOne},
Timer Two Latest: ${timerValTwo},
Timer Three Latest: ${timerValThree}`
);
}
);
}
开发者ID:zwvista,项目名称:SampleMisc,代码行数:27,代码来源:combining.service.ts
示例7: of
observable1 = constructorZone1.run(() => {
const source = of(1, 2, 3);
const input = of(4, 5, 6);
return combineLatest(source, input, (x: number, y: number) => {
return x + y;
});
});
开发者ID:angular,项目名称:zone.js,代码行数:7,代码来源:rxjs.Observable.combine.spec.ts
示例8: switchMap
switchMap(plans => {
const planDetails = plans.map(plan => {
return fetchServicePlanDetail(parent.id, plan.name).pipe(
retry(2),
map(({ response }) => ({ name: plan.name, ...response }))
);
});
return combineLatest(...planDetails);
})
开发者ID:dcos,项目名称:dcos-ui,代码行数:9,代码来源:index.ts
示例9: memoize
export const watchFormControl = memoize((control: FormControl) => concat(
of(control),
combineLatest(
control.statusChanges,
control.valueChanges
).pipe(
map(() => control)
)
));
开发者ID:cyph,项目名称:cyph,代码行数:9,代码来源:form-controls.ts
示例10: it
it('should combineLatest the provided observables', () => {
const firstSource = hot('----a----b----c----|');
const secondSource = hot('--d--e--f--g--|');
const expected = '----uv--wx-y--z----|';
const combined = combineLatest(firstSource, secondSource,
(a, b) => '' + a + b);
expectObservable(combined).toBe(expected, {u: 'ad', v: 'ae', w: 'af', x: 'bf', y: 'bg', z: 'cg'});
});
开发者ID:DallanQ,项目名称:rxjs,代码行数:10,代码来源:combineLatest-spec.ts
示例11: ngOnInit
ngOnInit() {
this.block$ = combineLatest(
this.config.currentChain$,
this.route.paramMap.pipe(
switchMap(params => of(params.get('hash'))),
filter((hash): hash is string => typeof hash === 'string')
)
).pipe(
switchMap(([chain, hash]) => this.apiService.streamBlock(chain, hash))
);
}
开发者ID:bitjson,项目名称:bitcore,代码行数:11,代码来源:block.page.ts
示例12: googleSignIn
googleSignIn() {
combineLatest(this.auth.signIn(), this.route.queryParams, (res: boolean, param: Params) => {
return { success: res, redirectTo: param['return'] || '/' };
})
.subscribe((signInRes: { success: boolean, redirectTo: string }) => {
if (signInRes.success) {
this.router.navigateByUrl(signInRes.redirectTo);
} else {
console.error('login failed');
}
})
}
开发者ID:cuponthetop,项目名称:bg-hub,代码行数:12,代码来源:login.component.ts
示例13: ngOnInit
ngOnInit(): void {
combineLatest(this.route.parent.url, this.route.params)
.subscribe((route) => {
const url = route[0];
const params = route[1];
if(url[1].path == 'new') {
this.create(params);
} else {
this.load(params['id']);
}
});
}
开发者ID:pigatron-industries,项目名称:pigatron-web,代码行数:12,代码来源:abstractform.component.ts
示例14: queryCosmosForUIVersions
function getUpdateAvailable$() {
const uiMetaData$ = getUiMetadata$();
const cosmosVersions$ = queryCosmosForUIVersions();
return combineLatest<[UIMetadata, Package]>([
uiMetaData$,
cosmosVersions$
]).pipe(
map(([uiMetaData, packageInfo]) =>
versionUpdateAvailable(packageInfo, uiMetaData)
)
);
}
开发者ID:dcos,项目名称:dcos-ui,代码行数:12,代码来源:streams.ts
示例15: statusChanges
get statusChanges(): Observable<any | null> {
let statusChanges = this.ngControl.statusChanges;
if (this.parentForm) {
statusChanges = combineLatest(
statusChanges,
this.parentForm.statusChanges,
);
}
return statusChanges;
}
开发者ID:suiruiw,项目名称:geeks-diary,代码行数:12,代码来源:form-field-control.ts
示例16: ngOnInit
ngOnInit() {
this.enableRealTime$ = combineLatest(
this.newUrlStateNotificationService.onUrlStateChange$.pipe(
map((urlService: NewUrlStateNotificationService) => urlService.isRealTimeMode())
),
this.webAppSettingDataService.useActiveThreadChart()
).pipe(
map(([isRealTimeMode, useActiveThreadChart]: boolean[]) => isRealTimeMode && useActiveThreadChart)
);
this.webAppSettingDataService.getVersion().subscribe((version: string) => {
this.analyticsService.trackEvent(TRACKED_EVENT_LIST.VERSION, version);
});
}
开发者ID:young891221,项目名称:pinpoint,代码行数:13,代码来源:main-page.component.ts
示例17: data
data(): Observable<ProgramData> {
const data = publishDocument(this.ref);
return combineLatest(
data,
data.pipe(
switchMap(({ requirements }) => this.parse(JSON.parse(requirements)))
)
).pipe(
map(([data, requirements]) => {
return { ...data, requirements } as ProgramData;
})
);
}
开发者ID:kevmo314,项目名称:canigraduate.uchicago.edu,代码行数:13,代码来源:program.ts
示例18: getCurrentNodes
/**
* Get an observable of the current nodes (the ones that match the current URL)
* We use `publishReplay(1)` because otherwise subscribers will have to wait until the next
* URL change before they receive an emission.
* See above for discussion of using `connect`.
*/
private getCurrentNodes(navigationViews: Observable<NavigationViews>): Observable<CurrentNodes> {
const currentNodes = combineLatest(
navigationViews.pipe(map(views => this.computeUrlToNavNodesMap(views))),
this.location.currentPath,
(navMap, url) => {
const urlKey = url.startsWith('api/') ? 'api' : url;
return navMap.get(urlKey) || { '' : { view: '', url: urlKey, nodes: [] }};
})
.pipe(publishReplay(1));
(currentNodes as ConnectableObservable<CurrentNodes>).connect();
return currentNodes;
}
开发者ID:DallanQ,项目名称:rxjs,代码行数:19,代码来源:navigation.service.ts
示例19: observableCombineLatest
/**
* Returns an Observable which emits ``true`` when all PeriodBuffers given are
* _complete_.
* Returns false otherwise.
*
* A PeriodBuffer for a given type is considered _complete_ when both of these
* conditions are true:
* - it is the last PeriodBuffer in the content for the given type
* - it has finished downloading segments (it is _full_)
*
* Simply put a _complete_ PeriodBuffer for a given type means that every
* segments needed for this Buffer have been downloaded.
*
* When the Observable returned here emits, every Buffer are finished.
* @param {...Observable} buffers
* @returns {Observable}
*/
export default function areBuffersComplete(
...buffers : Array<Observable<IMultiplePeriodBuffersEvent>>
) : Observable<boolean> {
/**
* Array of Observables linked to the Array of Buffers which emit:
* - true when the corresponding buffer is considered _complete_.
* - false when the corresponding buffer is considered _active_.
* @type {Array.<Observable>}
*/
const isCompleteArray : Array<Observable<boolean>> = buffers
.map((buffer) => {
return buffer.pipe(
filter((evt) => {
return evt.type === "complete-buffer" || evt.type === "active-buffer";
}),
map((evt) => evt.type === "complete-buffer"),
startWith(false),
distinctUntilChanged()
);
});
return observableCombineLatest(...isCompleteArray)
.pipe(
map((areComplete) => areComplete.every((isComplete) => isComplete)),
distinctUntilChanged()
);
}
开发者ID:canalplus,项目名称:rx-player,代码行数:44,代码来源:are_buffers_complete.ts
注:本文中的rxjs.combineLatest函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论