2011-09-19 62 views
4

可以说我有这个炎热的观察到一个发布连续数每秒5分钟:无扩展方法来热观察的时间间隔转换为冷观察到

1,2,...,N,OnCompleted

在某个时间点,在热点观察点开始后,但在它完成之前,我订阅它直到它完成。

我得到数字:x,x + 1,x + 2,... n。

我想将收到的值转换为冷观察值。 有没有特殊的操作符?

我知道我可以只使用

Observable.Create(observer => hotObservable.Subscribe(onNext, onCompleted, onError); 

但我敢肯定有一个的Rx扩展方法我失去了,这不只是

回答

7

只需使用重播主题。

ReplaySubject<int> sub = new ReplaySubject<int>(); 
hotObservable.Subscribe(sub); 
//Now any one can subscribe to sub and it will get all items that hot observable sent to replay subject 
+0

正是我在找的东西:D –