system.reactive

A cache serving updates and new values as “DistinctLatest” and full cache contents upon subscription

淺唱寂寞╮ 提交于 2020-01-04 23:42:49
问题 I'm trying to implement a cache using a ReplaySubject like follows, but I'm unable to solve the situation using Rx. See code and accompanying tests. The trouble is that the cache drops the newest entries and preserves the oldest. public static class RxExtensions { /// <summary> /// A cache that keeps distinct elements where the elements are replaced by the latest. Upon subscription the subscriber should receive the full cache contents. /// </summary> /// <typeparam name="T">The type of the

Observable.Range being repeated?

不想你离开。 提交于 2020-01-04 16:51:42
问题 New to Rx -- I have a sequence that appears to be functioning correctly except for the fact that it appears to repeat. I think I'm missing something around calls to Select() or SelectMany() that triggers the range to re-evaluate. Explanation of Code & What I'm trying to Do For all numbers, loop through a method that retrieves data (paged from a database). Eventually, this data will be empty (I only want to keep processing while it retrieves data For each of those records retrieved, I only

Observable.Range being repeated?

爱⌒轻易说出口 提交于 2020-01-04 16:51:16
问题 New to Rx -- I have a sequence that appears to be functioning correctly except for the fact that it appears to repeat. I think I'm missing something around calls to Select() or SelectMany() that triggers the range to re-evaluate. Explanation of Code & What I'm trying to Do For all numbers, loop through a method that retrieves data (paged from a database). Eventually, this data will be empty (I only want to keep processing while it retrieves data For each of those records retrieved, I only

Where is Observable.Iterate() in Rx 1.0.10621.0/1.1.10621.0

岁酱吖の 提交于 2020-01-04 06:12:45
问题 I'm finding a few examples online of Reactive Extensions that require the use of Observable.Iterate(), but the package from NuGet, Rx version 1.0.10621.0 does not seem to include it. Unless I'm doing it all wrong? I assume that it was renamed, but I can't find any posts regarding that. Anyone know? 回答1: From Rx Forum: Wes Dyer: What about Observable.Iterate? Use the Observable.Create that takes a Func, Task> which works exactly the same as Iterate except that it uses async await to drive it.

Using Subject to decouple Observable subscription and initialisation

时光总嘲笑我的痴心妄想 提交于 2020-01-04 05:27:35
问题 I have an API which exposes an IObservable Status. But this status depends on an underlying observable source which has to be initialised via Init . What I'd like to do is protect the users from having to do things in the right order: as it currently stands, if they try to subscribe to the Status before performing an Init , they get an exception because they source is not initialised. So I had the genius idea of using a Subject to decouple the two: the external user subscribing to my Status

RXJS draw line on html5 canvas

丶灬走出姿态 提交于 2020-01-04 05:05:45
问题 I'm trying to achieve the same effect I'm posting here using Reactive Extensions for Javascript (RX-JS). I'm a bit puzzled on how to do it. Here is the page: <!DOCTYPE html> <html> <head> <title>drag and drop</title> </head> <style type="text/css"> canvas { border:1px solid steelblue; background-color: whitesmoke; } </style> <body> <canvas id="canvas" width=300 height=300></canvas> <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script type="text

How to do I show progress when using Reactive Extensions in C#

一个人想着一个人 提交于 2020-01-04 02:15:08
问题 Am using reactive extensions in C# to perform some calculations. Here is how my code looks like so far. I have tried to wrap the code around so that I can show progress while to executing a series of tasks within my Calculate method Here is the observable IObservable<ResultWithProgress<SampleResult>> Calculate(){ return Observable.Create<ResultWithProgress<SampleResult>>(obs => { var someTask = DoSomeTask1(); obs.OnNext(new ResultWithProgress(){Progress = 25, ProgressText ="Completed Task1"})

IObservable of keys pressed

Deadly 提交于 2020-01-03 20:04:45
问题 So I can experiment with Reactive Extensions, I'd like to create an IObservable of keys pressed by the user. How can I do this? This is for a C# console application 回答1: Try this to get an observable sequence of read keys: IObservable<System.ConsoleKeyInfo> keys = Observable .Defer(() => Observable .Start(() => Console.ReadKey())) .Repeat(); I tested this and it worked like a treat. 回答2: The blocking versions of ReadKey() have a problem, in that if you dispose the subscription, it still

Why does Subject<T>.Dispose does not dispose current subscriptions?

此生再无相见时 提交于 2020-01-03 19:04:18
问题 Hi I've been thinking for some time that Subject<T> disposes all the subscriptions based on it if you manually call its Dispose method. But I've recently found it doesn't work that way, it just clears its inner collection of observers and substitutes it with a DisposedObserver helper class instance. I found myself a little confused about the behaviour, just assumed that the "normal" would be just propagate and dispose all the suscribers. Later, trying to figure out why is designed this way, I

Rx Buffer with timeout since first new group element

时光总嘲笑我的痴心妄想 提交于 2020-01-03 15:56:30
问题 pretty new to Rx world, and I need to implement the following behavior: I need the observable to gather values and emit them as a list once I have at least N items, or if a T amount of time passed since the first item of the group was emitted. I read the docs again and again, pretty sure it'll use buffer(timespan, unit, count[, scheduler]) But the issue is that the timespan here is depending on the last group of items. And if possible, I would also need to be able to flush (force the emission