rx.net

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

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 =

Rx.Net multiple Mergerd Observables & Throttle() not working as expected

折月煮酒 提交于 2020-01-06 07:04:54
问题 I have multiple source Obserables that emit Unit.Default instances merged into one stream and the later being .Throttle()'ed to yield a result after 300ms of 'silence' var columnVisibilityChangedObservable = Observable.FromEventPattern<ColumnVisibilityChangedEventArgs>( handler => this.ColumnVisibilityChanged += handler, handler => this.ColumnVisibilityChanged -= handler) .Select(_ => Unit.Default); var dataBindingCompleteObservable = Observable.FromEventPattern

Rx.Net : Calling multiple IObservable in SelectMany

烂漫一生 提交于 2019-12-25 02:34:14
问题 Please Note: This is continuation of the question posted earlier but the solution of interest is of a different situation. I am trying to make multiple calls to the methods that each return IObservable but the values being returned back in the SelectMany statement is a Task and hence the following Subscribe statement does not compile . This is the code snippet var myWorkList = new List<MyWork> { new MyWork(),// MyWork.Execute(data) returns IObservable new MyWork() }.ToObservable(); var

Rx.Net: Chaining subscribers - alternative approach?

对着背影说爱祢 提交于 2019-12-24 21:59:27
问题 How can I re-write this code so that I don't have to chain Subscribers like below? Reason for asking is, this style will limit in an observable depending on another observable due to the style of the code, it can get confusing. var results = myService .GetData(accountId) // returns IObservable .Subscribe(data => { new MyWork().Execute(data) // returns IObservable .Subscribe(result => { myResults.Add(result); WriteLine($"Result Id: {result.Id}"); WriteLine($"Result Status: {result.Pass}"); });

How to Subscribe to IObservable Sequence, force completion, and retrieve all data without race conditions

孤街醉人 提交于 2019-12-23 03:45:31
问题 There is a pattern I'm having trouble with when working with observables. I am working with a bluetooth device. I send a message to that device telling it to do something and notify me of the result or results. The device starts sending notifications (could go for 10ms or 20s) I wait for the device to finish sending notifications. sometimes this will be a specific message from the device and sometimes I just won't receive any more messages for a timeout period. I convert the messages to a

Take the last item pushed to an Observable (Sequence)

霸气de小男生 提交于 2019-12-14 02:12:04
问题 I have an IObservable<Item> inside a class and I want to expose a read-only property that provides the last item pushed to the observable at a given time. So it will provide a single value of Item . If no value has been pushed, then it will have to return a default value. How can I do this without having to subscribe to the observable and having a "backing field"? 回答1: Just to supplement @Asti's answer a bit here, and perhaps help you with your frustration: An observable isn't a physical

How to combine GroupedObservables in rx.net?

倾然丶 夕夏残阳落幕 提交于 2019-12-13 20:14:09
问题 I have one observable that I use GroupBy on to get a number of streams. I actually want a Scan result over each sub-stream. Let's say the observable is over product prices and the scan result is average price per product type. I have another stream of events pertaining to those 'products' (let's say "show product price" events) and I want to combine it with the previous stream's latest product price. So the Scan output per group needs to be combined with each element of the event stream to

How to implement my own operator in rx.net

对着背影说爱祢 提交于 2019-12-11 07:38:41
问题 I need the functionality of a hysteresis filter in RX. It should emit a value from the source stream only when the previously emitted value and the current input value differ by a certain amount. As a generic extension method, it could have the following signature: public static IObservable<T> HysteresisFilter<T>(this IObservable<t> source, Func<T/*previously emitted*/, T/*current*/, bool> filter) I was not able to figure out how to implement this with existing operators. I was looking for