本文整理匯總了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()));
}