rx.net

How to merge two observables with early completion

╄→гoц情女王★ 提交于 2021-02-11 08:36:15
问题 The behavior of the built-in Merge operator is to complete when both sources are completed. I am searching for a variant of this operator that produces an observable that completes when any of the two source observables completes. For example if the first observable complete successfully and later the second observable complete with an exception, I want this exception to be ignored. I came up with an implementation that concatenates a special sentinel exception to both enumerables, and then

Make an IObservable subscription concurrent

99封情书 提交于 2021-02-08 08:28:24
问题 I have the following code string dataDirectory = _settingsProvider.DataSettings.BaseDirectory; _solverManagementService.MergedPointCloudProducer(dataDirectory, cancellationToken) .Subscribe(PointCloudMergerCompleted); where the SolverManagementService _solverManagementService is Public class SolverManagementService : ISolverManagementService { public IObservable<IPointCloud> MergedPointCloudProducer(string dataDirectory, CancellationToken token) { return Observable.Create<IPointCloud>(

How to merge multiple observables with order preservation and maximum concurrency?

旧街凉风 提交于 2021-02-05 06:39:25
问题 I searched for a duplicate and didn't find any. What I have is a nested observable IObservable<IObservable<T>> , and I want to flatten it to a IObservable<T> . I don't want to use the Concat operator because it delays the subscription to each inner observable until the completion of the previous observable. This is a problem because the inner observables are cold, and I want them to start emitting T values immediately after they are emitted by the outer observable. I also don't want to use

How to bind a non-disposable object with each subscription of a cold observable?

纵然是瞬间 提交于 2021-02-04 08:37:04
问题 Sorry if this question has been asked before, but I can't find a duplicate. Also sorry for asking too many questions lately! I am probably searching for a custom Observable.Using method, that is not restricted to disposable resources. What I have is a cold IObservable that maintains some internal state, for example a Random instance. This instance should be bound not with the IObservable itself, but with each of its subscriptions. Each subscriber should use a different instance of this

How to convert an IGroupedObservable to IGrouping?

故事扮演 提交于 2021-01-29 08:14:59
问题 I have an observable sequence of elements that have a char Key property, that has values in the range from 'A' to 'E' . I want to group these elements based on this key. After grouping them I want the result to by an observable of groups, so that I can process each group separately. My problem is that I can't find a nice way to preserve the key of each group in the final observable. Here is an example of what I am trying to do: var observable = Observable .Interval(TimeSpan.FromMilliseconds

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

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

Create observable from periodic async request

扶醉桌前 提交于 2020-12-03 06:35:27
问题 I want a generic way to convert an asynchronous method to an observable. In my case, I'm dealing with methods that uses HttpClient to fetch data from an API. Let's say we have the method Task<string> GetSomeData() that needs to become a single Observable<string> where the values is generated as a combination of: Repeated periodic calls to GetSomeData() (for example every x seconds) Manually triggered calls to GetSomeData() at any given time (for example when user hits refresh). Since there is

Create observable from periodic async request

早过忘川 提交于 2020-12-03 06:34:50
问题 I want a generic way to convert an asynchronous method to an observable. In my case, I'm dealing with methods that uses HttpClient to fetch data from an API. Let's say we have the method Task<string> GetSomeData() that needs to become a single Observable<string> where the values is generated as a combination of: Repeated periodic calls to GetSomeData() (for example every x seconds) Manually triggered calls to GetSomeData() at any given time (for example when user hits refresh). Since there is