本文整理汇总了TypeScript中rxjs/operators.timeoutWith函数的典型用法代码示例。如果您正苦于以下问题:TypeScript timeoutWith函数的具体用法?TypeScript timeoutWith怎么用?TypeScript timeoutWith使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了timeoutWith函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should support a date', () => {
const o = of('a', 'b', 'c').pipe(timeoutWith(new Date(), of(1, 2, 3))); // $ExpectType Observable<string | number>
const p = of('a', 'b', 'c').pipe(timeoutWith(new Date(), [1, 2, 3])); // $ExpectType Observable<string | number>
const q = of('a', 'b', 'c').pipe(timeoutWith(new Date(), Promise.resolve(5))); // $ExpectType Observable<string | number>
const r = of('a', 'b', 'c').pipe(timeoutWith(new Date(), new Set([1, 2, 3]))); // $ExpectType Observable<string | number>
const s = of('a', 'b', 'c').pipe(timeoutWith(new Date(), 'foo')); // $ExpectType Observable<string>
});
示例2: establishCache
/**
* initializes the cache by subscribing topic - each message is stored internally
* @method establishCache
* @param {string} topic pattern to subscribe
*/
public establishCache(topic: string): Observable<Map<string, Ha4usMessage>> {
this.caching$.next(topic)
return this.cache$.pipe(
take(1),
timeoutWith(500, of(new Map<string, Ha4usMessage>()))
)
}
示例3: mergeMap
mergeMap((aObject: Ha4usObject) => {
return this.$states.observe(aObject.topic).pipe(
timeoutWith(100, of({})),
take(1),
map((state: Ha4usMessage) => {
delete state.topic
delete state.match
return {
object: aObject,
state: state,
}
})
)
}),
示例4: checkFile
checkFile(file: File): Observable<ValidationMetadata> {
return this.auroraValidation(file)
.validate().pipe(
timeoutWith(500, this.nativeValidation(file).validate()));
}