system.reactive

Running histogram stream with Rx

元气小坏坏 提交于 2021-01-27 02:36:12
问题 I have the following single letter stream A B C A D B A C D And from this stream, I would like a stream of running count per letter (A,1) (A,1), (B,1) (A,1), (B,1), (C,1) (A,2), (B,1), (C,1) (A,2), (B,1), (C,1), (D,1) (A,2), (B,2), (C,1), (D,1) (A,3), (B,2), (C,1), (D,1) (A,3), (B,2), (C,2), (D,1) (A,3), (B,2), (C,2), (D,2) , i.e at each new letter, the totals are updated and emitted. I guess this problem is fairly language agnostic, so don't hesitate to propose a solution in your language of

Why is IEnumerable.ToObservable so slow?

坚强是说给别人听的谎言 提交于 2021-01-27 00:53:19
问题 I am trying to enumerate a large IEnumerable once, and observe the enumeration with various operators attached ( Count , Sum , Average etc). The obvious way is to transform it to an IObservable with the method ToObservable, and then subscribe an observer to it. I noticed that this is much slower than other methods, like doing a simple loop and notifying the observer on each iteration, or using the Observable.Create method instead of ToObservable . The difference is substantial: it's 20-30

Reactive Throttle Returning All Items Added Within The TimeSpan

岁酱吖の 提交于 2021-01-21 07:18:32
问题 Given an IObservable<T> is there a way to use Throttle behaviour (reset a timer when an item is added, but have it return a collection of all the items added within that time? Buffer provides a similar functionality it that it chunks the data up into IList<T> on every time span or count. But I need that time to reset each time an item is added. I've seen a similar question here, Does reactive extensions support rolling buffers?, but the answers don't seem ideal and it's a little old so I

Reactive Throttle Returning All Items Added Within The TimeSpan

▼魔方 西西 提交于 2021-01-21 07:16:05
问题 Given an IObservable<T> is there a way to use Throttle behaviour (reset a timer when an item is added, but have it return a collection of all the items added within that time? Buffer provides a similar functionality it that it chunks the data up into IList<T> on every time span or count. But I need that time to reset each time an item is added. I've seen a similar question here, Does reactive extensions support rolling buffers?, but the answers don't seem ideal and it's a little old so I

Reactive Throttle Returning All Items Added Within The TimeSpan

折月煮酒 提交于 2021-01-21 07:11:42
问题 Given an IObservable<T> is there a way to use Throttle behaviour (reset a timer when an item is added, but have it return a collection of all the items added within that time? Buffer provides a similar functionality it that it chunks the data up into IList<T> on every time span or count. But I need that time to reset each time an item is added. I've seen a similar question here, Does reactive extensions support rolling buffers?, but the answers don't seem ideal and it's a little old so I

Enforcing one async observable at a time

旧时模样 提交于 2021-01-02 23:49:30
问题 I'm trying to integrate some TPL async into a larger Rx chain using Observable.FromAsync , like in this small example: using System; using System.Reactive.Linq; using System.Threading.Tasks; namespace rxtest { class Program { static void Main(string[] args) { MainAsync().Wait(); } static async Task MainAsync() { await Observable.Generate(new Random(), x => true, x => x, x => x.Next(250, 500)) .SelectMany((x, idx) => Observable.FromAsync(async ct => { Console.WriteLine("start: " + idx.ToString

Enforcing one async observable at a time

心已入冬 提交于 2021-01-02 23:46:29
问题 I'm trying to integrate some TPL async into a larger Rx chain using Observable.FromAsync , like in this small example: using System; using System.Reactive.Linq; using System.Threading.Tasks; namespace rxtest { class Program { static void Main(string[] args) { MainAsync().Wait(); } static async Task MainAsync() { await Observable.Generate(new Random(), x => true, x => x, x => x.Next(250, 500)) .SelectMany((x, idx) => Observable.FromAsync(async ct => { Console.WriteLine("start: " + idx.ToString

How to fix the inconsistency of the Publish().RefCount() behavior?

狂风中的少年 提交于 2020-12-23 12:10:55
问题 Recently I stumbled upon an interesting statement by Enigmativity about the Publish and RefCount operators: You're using the dangerous .Publish().RefCount() operator pair which creates a sequence that can't be subscribed to after it completes. This statement seems to oppose Lee Campbell's assessment about these operators. Quoting from his book Intro to Rx: The Publish/RefCount pair is extremely useful for taking a cold observable and sharing it as a hot observable sequence for subsequent

How can I implement an exhaustMap handler in Rx.Net?

非 Y 不嫁゛ 提交于 2020-12-23 04:57:23
问题 I am looking for something similar to the exhaustMap operator from rxjs , but RX.NET does not seem to have such an operator. What I need to achieve is that, upon every element of the source stream, I need to start an async handler, and until it finishes, I would like to drop any elements from the source. As soon as the handler finishes, resume taking elements. What I don't want is to start an async handler upon every element - while the handler runs, I want to drop source elements. I also

What's the Rx.NET equivalent to flatMapIterable?

久未见 提交于 2020-12-13 03:43:39
问题 Today I finally stumbled upon the solution of a really trivial RX problem: Suppose you have an Observable which returns Lists of items. Like Observable<List<String>> . You often receive something like this as responses from web APIs. However chances are you want to operate on the single items, in this case the Strings. flatMapIterable to the rescue! This handy operator flattens a stream of Iterables into a stream generated from the single items of these Iterables by means of a mapping