system.reactive

RX - rethrow an error in containing method

泄露秘密 提交于 2021-02-20 10:31:43
问题 I need to translate an error in an RX stream ( IObservable ) into an exception in the method that contains the subscription to the stream (because of this issue https://github.com/aspnet/SignalR/pull/1331 , Whereby errors arent serialised to clients.) Once this issue is fixed I will revert to handling error properly e.g. I have the following method public IObservable<StreamItem> LiveStream() { _mySvc.Start(); return _mySvc.ThingChanged(); } So I have tried to subscribe to the stream and

Taking a snapshot of ReplaySubject<T> buffer

谁都会走 提交于 2021-02-19 08:35:14
问题 I have a large ReplaySubject that allows subscribers to receive the replay buffer and future notifications as normal. In addition, I would like to be able to take a "snapshot" of the current buffer and return that as a list synchronously, without having to subscribe. Is there a way to do this? thanks 回答1: Can you not just subscribe, receive the items, then unsubscribe? public static List<T> Snapshot<T>(ReplaySubject<T> subject) { List<T> snapshot = new List<T>(); using (subject.Subscribe(item

File Monitoring System Reactive Programming

余生长醉 提交于 2021-02-19 07:39:18
问题 I am using C#.I am new to reactive programming. Using reactive programming, I want to create a folder monitoring system which will invoke if folder A contains any file if yes then it will grab that file & process it and move it in Folder B. Let say, Folder A is empty first.User adds some files into folder A realtime. System detects that new files has been added & it will process it one by one or simultaneously. I am not able to understand what should I use Create or Interval and after that

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

Create a IObservableList from a list of IObservable

风格不统一 提交于 2021-02-11 04:30:05
问题 I'm looking for a reactive object that implement IObservable<IReadOnlyList<T>> and IList<IObservable<T>> . That's it, I would like to be able to write : var list = new MyReactiveList<int>(); var item = new new Subject<int>(); list.Subscribe(values => Console.WriteLine($"[{string.Join(", ", values)}]")); list.Add(item); item.OnNext(1); // Will print out [1] 回答1: First up, your code that you posted in your question doesn't compile. I have fixed it the best I can: var list = new MyReactiveList

Create a IObservableList from a list of IObservable

让人想犯罪 __ 提交于 2021-02-11 04:25:28
问题 I'm looking for a reactive object that implement IObservable<IReadOnlyList<T>> and IList<IObservable<T>> . That's it, I would like to be able to write : var list = new MyReactiveList<int>(); var item = new new Subject<int>(); list.Subscribe(values => Console.WriteLine($"[{string.Join(", ", values)}]")); list.Add(item); item.OnNext(1); // Will print out [1] 回答1: First up, your code that you posted in your question doesn't compile. I have fixed it the best I can: var list = new MyReactiveList

Reset and Dispose observable subscriber, Reactive Extensions

▼魔方 西西 提交于 2021-02-10 15:50:59
问题 Suppose I have this : public class UploadDicomSet { public UploadDicomSet() { var cachCleanTimer = Observable.Interval(TimeSpan.FromMinutes(2)); cachCleanTimer.Subscribe(CheckUploadSetList); //Start subscriber } void CheckUploadSetList(long interval) { //Stop and dispose subscriber } public void AddDicomFile(SharedLib.DicomFile dicomFile) { //Renew subscriber, call CheckUploadSetList 2 minutes later } } 1- in CheckUploadSetList I want to dispose or finish observable 2- in AddDicomFile I want

Reset and Dispose observable subscriber, Reactive Extensions

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-10 15:50:02
问题 Suppose I have this : public class UploadDicomSet { public UploadDicomSet() { var cachCleanTimer = Observable.Interval(TimeSpan.FromMinutes(2)); cachCleanTimer.Subscribe(CheckUploadSetList); //Start subscriber } void CheckUploadSetList(long interval) { //Stop and dispose subscriber } public void AddDicomFile(SharedLib.DicomFile dicomFile) { //Renew subscriber, call CheckUploadSetList 2 minutes later } } 1- in CheckUploadSetList I want to dispose or finish observable 2- in AddDicomFile I want

Rx – Distinct with timeout?

眉间皱痕 提交于 2021-02-10 14:42:14
问题 I’m wondering is there any way to implement Distinct in Reactive Extensions for .NET in such way that it will be working for given time and after this time it should reset and allow values that are come back again. I need this for hot source in application that will be working for whole year with now stops so I’m worried about performance and I need those values to be allowed after some time. There is also DistinctUntilChanged but in my case values could be mixed – for example: A A X A,

Rx – Distinct with timeout?

↘锁芯ラ 提交于 2021-02-10 14:40:24
问题 I’m wondering is there any way to implement Distinct in Reactive Extensions for .NET in such way that it will be working for given time and after this time it should reset and allow values that are come back again. I need this for hot source in application that will be working for whole year with now stops so I’m worried about performance and I need those values to be allowed after some time. There is also DistinctUntilChanged but in my case values could be mixed – for example: A A X A,