99re热这里只有精品视频,7777色鬼xxxx欧美色妇,国产成人精品一区二三区在线观看,内射爽无广熟女亚洲,精品人妻av一区二区三区

RxJS repeat

2020-10-14 10:30 更新

返回一個 Observable,它將在源流完成時最多計數(shù)一次重新訂閱源流。

repeat<T>(count: number = -1): MonoTypeOperatorFunction<T>

參量

計數(shù) 可選的。默認值為-1。重復源可觀察項的次數(shù),計數(shù)為 0 將產(chǎn)生一個空的可觀察項。

returns

MonoTypeOperatorFunction<T>:一個 Observable,它將在源流完成時最多計數(shù)一次重新訂閱源流。

描述

重復源上發(fā)出的所有值。就像 retry,但是用于非錯誤情況。

重復大理石圖

與相似 retry,此運算符在無錯誤的情況下重復由源發(fā)出的項目流。重復對于創(chuàng)建具有某些重復模式或節(jié)奏的可觀察對象很有用。

注意:repeat(0)返回一個可觀察的空值,repeat()并將永遠重復

重復消息流

import { of } from 'rxjs';
import { repeat, delay } from 'rxjs/operators';


const source = of('Repeat message');
const example = source.pipe(repeat(3));
example.subscribe(x => console.log(x));


// Results
// Repeat message
// Repeat message
// Repeat message

重復3個值,兩次

import { interval } from 'rxjs';
import { repeat, take } from 'rxjs/operators';


const source = interval(1000);
const example = source.pipe(take(3), repeat(2));
example.subscribe(x => console.log(x));


// Results every second
// 0
// 1
// 2
// 0
// 1
// 2

也可以看看

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號