system.reactive

Using AsObservable to observe TPL Dataflow blocks without consuming messages

夙愿已清 提交于 2020-07-08 09:40:37
问题 I have a chain of TPL Dataflow blocks and would like to observe progress somewhere inside the system. I am aware that I could just jam a TransformBlock into the mesh where I want to observe, get it to post to a progress updater of some variety and then return the message unchanged to the next block. I don't love this solution as the block would be purely there for its side-effect and I would also have to change the block linking logic wherever I want to observe. So I wondered if I could use

Count of observers in a Rx Subject

試著忘記壹切 提交于 2020-05-29 04:37:17
问题 With Rx, what is the best way to get the number of current observers in a Subject? I have a scenario where I want to publish a message, but only if there are observers. If there are no observers, I need to do something else. To get around this issue, what I've done is created my own ISubject implementation and expose a count of an internal IObserver collection. I'm sure there must be an out of the box way of doing this, I'm just not fully familiar with what Rx has to offer. Thanks! 回答1: You

Why does repeated Enumerable to Observable conversion block

孤街浪徒 提交于 2020-05-09 02:48:22
问题 This is a rather educational, out of curiosity question. Consider the following snippet: var enumerable = Enumerable.Range(0, 5); var observable = enumerable.ToObservable(); var enu = observable.Concat(observable).ToEnumerable(); enu.ToObservable().SubscribeDebug(); Where SubscribeDebug subscribes a simple observer: public class DebugObserver<T> : IObserver<T> { public void OnCompleted() { Debug.WriteLine("Completed"); } public void OnError(Exception error) { Debug.WriteLine("Error"); }

The Observable.Repeat is unstoppable, is it a bug or a feature?

独自空忆成欢 提交于 2020-04-18 05:50:08
问题 I noticed something strange with the behavior of the Repeat operator, when the source observable's notifications are synchronous. The resulting observable cannot be stopped with a subsequent TakeWhile operator, and apparently continues running forever. For demonstration I created a source observable that produces a single value, which it is incremented on every subscription. The first subscriber gets the value 1, the second gets the value 2 etc: int incrementalValue = 0; var incremental =

The Observable.Repeat is unstoppable, is it a bug or a feature?

半腔热情 提交于 2020-04-18 05:50:02
问题 I noticed something strange with the behavior of the Repeat operator, when the source observable's notifications are synchronous. The resulting observable cannot be stopped with a subsequent TakeWhile operator, and apparently continues running forever. For demonstration I created a source observable that produces a single value, which it is incremented on every subscription. The first subscriber gets the value 1, the second gets the value 2 etc: int incrementalValue = 0; var incremental =

EventBus/PubSub vs (reactive extensions) RX with respect to code clarity in a single threaded application

拥有回忆 提交于 2020-03-12 06:57:31
问题 Currently, I am using an EventBus/PubSub architecture/pattern with Scala (and JavaFX) to implement a simple note organizing app (sort of like an Evernote client with some added mind mapping functionality) and I have to say that I really like EventBus over the observer pattern. Here are some EventBus libraries : https://code.google.com/p/guava-libraries/wiki/EventBusExplained http://eventbus.org (currently seems to be down) this is the one I am using in my implementation. http://greenrobot

EventBus/PubSub vs (reactive extensions) RX with respect to code clarity in a single threaded application

跟風遠走 提交于 2020-03-12 06:57:08
问题 Currently, I am using an EventBus/PubSub architecture/pattern with Scala (and JavaFX) to implement a simple note organizing app (sort of like an Evernote client with some added mind mapping functionality) and I have to say that I really like EventBus over the observer pattern. Here are some EventBus libraries : https://code.google.com/p/guava-libraries/wiki/EventBusExplained http://eventbus.org (currently seems to be down) this is the one I am using in my implementation. http://greenrobot

Rx StartWith in async method not applying the starting value

跟風遠走 提交于 2020-03-03 10:49:48
问题 I am trying to inject an initial value into an RX stream using the StartWith method: public async Task<IObservable<Price>) Stream(Instrument instrumentDetails) { var initialPrice = await _svc.GetSomeInitialPrice(); var stream = _priceObserver.Stream .Where(o => o.Symbol == instrumentDetails.Symbol) .Select(o => GetPrice(o, instrumentDetails)); stream.StartWith(initialPrice); return stream; } however, the method is async due to the call to get the initial value. and it needs to be async all