system.reactive

Separate observable values by specific amount of time in RxJS

北战南征 提交于 2019-12-17 17:44:08
问题 What would be the most idiomatic way to yield values of an Observable by a specific amount of time? For example, let's say I have an Observable created from a big Array and I want to yield a value every 2 seconds. Is a combination of interval and selectMany the best way? 回答1: For your specific example, the idea is to map each value from the array to an observable that will yield its result after a delay, then concatenate the resulting stream of observables: var delayedStream = Rx.Observable

How can I alternately buffer and flow a live data stream in Rx

ぃ、小莉子 提交于 2019-12-17 11:51:57
问题 I have two streams. One is a flow of data (could be any type), the other is a boolean stream acting as a gate. I need to combine these into a stream that has the following behaviour: When the gate is open (most recent value was true) then the data should flow straight through When the gate is closed (most recent value was false) then the data should be buffered to be released as individual elements when the gate is next open The solution should preserve all elements of the data and preserve

Rx IObservable buffering to smooth out bursts of events

别说谁变了你拦得住时间么 提交于 2019-12-17 10:33:14
问题 I have an Observable sequence that produces events in rapid bursts (ie: five events one right after another, then a long delay, then another quick burst of events, etc.). I want to smooth out these bursts by inserting a short delay between events. Imagine the following diagram as an example: Raw: --oooo--------------ooooo-----oo----------------ooo| Buffered: --o--o--o--o--------o--o--o--o--o--o--o---------o--o--o| My current approach is to generate a metronome-like timer via Observable

Does reactive extensions support rolling buffers?

雨燕双飞 提交于 2019-12-17 07:23:27
问题 I'm using reactive extensions to collate data into buffers of 100ms: this.subscription = this.dataService .Where(x => !string.Equals("FOO", x.Key.Source)) .Buffer(TimeSpan.FromMilliseconds(100)) .ObserveOn(this.dispatcherService) .Where(x => x.Count != 0) .Subscribe(this.OnBufferReceived); This works fine. However, I want slightly different behavior than that provided by the Buffer operation. Essentially, I want to reset the timer if another data item is received. Only when no data has been

Does reactive extensions support rolling buffers?

百般思念 提交于 2019-12-17 07:23:08
问题 I'm using reactive extensions to collate data into buffers of 100ms: this.subscription = this.dataService .Where(x => !string.Equals("FOO", x.Key.Source)) .Buffer(TimeSpan.FromMilliseconds(100)) .ObserveOn(this.dispatcherService) .Where(x => x.Count != 0) .Subscribe(this.OnBufferReceived); This works fine. However, I want slightly different behavior than that provided by the Buffer operation. Essentially, I want to reset the timer if another data item is received. Only when no data has been

How can I see what my reactive extensions query is doing?

最后都变了- 提交于 2019-12-17 04:54:30
问题 I'm writing a complex Reactive Extensions query with lots of operators. How can I see what's going on? I'm asking and answering this as it comes up a fair bit and is probably of good general use. 回答1: You can append this function liberally to your Rx operators while you are developing them to see what's happening: public static IObservable<T> Spy<T>(this IObservable<T> source, string opName = null) { opName = opName ?? "IObservable"; Console.WriteLine("{0}: Observable obtained on Thread: {1}"

How can I see what my reactive extensions query is doing?

折月煮酒 提交于 2019-12-17 04:54:12
问题 I'm writing a complex Reactive Extensions query with lots of operators. How can I see what's going on? I'm asking and answering this as it comes up a fair bit and is probably of good general use. 回答1: You can append this function liberally to your Rx operators while you are developing them to see what's happening: public static IObservable<T> Spy<T>(this IObservable<T> source, string opName = null) { opName = opName ?? "IObservable"; Console.WriteLine("{0}: Observable obtained on Thread: {1}"

How can I see what my reactive extensions query is doing?

有些话、适合烂在心里 提交于 2019-12-17 04:54:01
问题 I'm writing a complex Reactive Extensions query with lots of operators. How can I see what's going on? I'm asking and answering this as it comes up a fair bit and is probably of good general use. 回答1: You can append this function liberally to your Rx operators while you are developing them to see what's happening: public static IObservable<T> Spy<T>(this IObservable<T> source, string opName = null) { opName = opName ?? "IObservable"; Console.WriteLine("{0}: Observable obtained on Thread: {1}"

.NET, event every minute (on the minute). Is a timer the best option?

只愿长相守 提交于 2019-12-17 04:52:23
问题 I want to do stuff every minute on the minute (by the clock) in a windows forms app using c#. I'm just wondering whats the best way to go about it ? I could use a timer and set its interval to 60000, but to get it to run on the minute, I would have to enable it on the minute precisely, not really viable. I could use a timer and set its interval to 1000. Then within its tick event, I could check the clocks current minute against a variable that I set, if the minute has changed then run my code

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