system.reactive

Is there a Rx method to repeat the previous value periodically when no values are incoming?

浪子不回头ぞ 提交于 2019-12-22 03:16:49
问题 A use case which I have encountered, and I suspect I can't be the only one, is for a method like: IObservable<T> Observable.RepeatLastValueDuringSilence(this IObservable<T> inner, TimeSpan maxQuietPeriod); which would return all the future items from the inner observable, but also, if the inner observable doesn't call OnNext for a certain period of time (maxQuietPeriod), it just repeats the last value (until of course inner calls OnCompleted or OnError). A justification would be for a service

Is there a Rx method to repeat the previous value periodically when no values are incoming?

六眼飞鱼酱① 提交于 2019-12-22 03:16:09
问题 A use case which I have encountered, and I suspect I can't be the only one, is for a method like: IObservable<T> Observable.RepeatLastValueDuringSilence(this IObservable<T> inner, TimeSpan maxQuietPeriod); which would return all the future items from the inner observable, but also, if the inner observable doesn't call OnNext for a certain period of time (maxQuietPeriod), it just repeats the last value (until of course inner calls OnCompleted or OnError). A justification would be for a service

Why is RefCount not working after all initial subscribers disconnect? (redux)

情到浓时终转凉″ 提交于 2019-12-21 20:17:47
问题 As requested by Lee Campbell, this is a follow-on question to this original. It is intended to present the question in the context of the use case I was attempting to solve. I have a WebApiService that wraps a raw web API and provides token management. That is, it keeps track of the authentication token, passing it through to the raw API. Here's an example of one of the public methods in the WebApiService : public IObservable<User> UpdateUserAsync(int id, UpdateUserRequest request) => this

Rx how to group by a key a complex object and later do SelectMany without “stopping” the stream?

断了今生、忘了曾经 提交于 2019-12-21 17:45:01
问题 This is related to my other question here. James World presented a solution as follows: // idStream is an IObservable<int> of the input stream of IDs // alarmInterval is a Func<int, TimeSpan> that gets the interval given the ID var idAlarmStream = idStream .GroupByUntil(key => key, grp => grp.Throttle(alarmInterval(grp.Key))) .SelectMany(grp => grp.IgnoreElements().Concat(Observable.Return(grp.Key))); <edit 2: Question: How do I start the timers immediately without waiting for the first

How to implement time expiry hot observable in RxJS (or general in Reactive Extensions)

◇◆丶佛笑我妖孽 提交于 2019-12-21 14:59:45
问题 I'd like to implement Time Expiry cache with RxJs. Here is example of "normal" cache: //let this represents "heavy duty job" var data = Rx.Observable.return(Math.random() * 1000).delay(2000); //and we want to cache result var cachedData = new Rx.AsyncSubject(); data.subscribe(cachedData); cachedData.subscribe(function(data){ //after 2 seconds, result is here and data is cached //next subscribe returns immediately data cachedData.subscribe(function(data2){ /*this is "instant"*/ }); }); When

How to implement time expiry hot observable in RxJS (or general in Reactive Extensions)

耗尽温柔 提交于 2019-12-21 14:59:01
问题 I'd like to implement Time Expiry cache with RxJs. Here is example of "normal" cache: //let this represents "heavy duty job" var data = Rx.Observable.return(Math.random() * 1000).delay(2000); //and we want to cache result var cachedData = new Rx.AsyncSubject(); data.subscribe(cachedData); cachedData.subscribe(function(data){ //after 2 seconds, result is here and data is cached //next subscribe returns immediately data cachedData.subscribe(function(data2){ /*this is "instant"*/ }); }); When

Rx debounce operator with first and last

南笙酒味 提交于 2019-12-21 11:28:10
问题 Is there any combination of rx operators so as to get the first and last debounced event? This is going to be used in master detail scenarios (or even seach scenarios) where we want immediate loading of first selected item and the last after user stops changing selection. This would prevent the debounce time to be injected when the user navigates slowly but also prevent bursts of changes. If debounce operator had an option "immediate" like underscore.js debounce functoin then a merge of the 2

Use of IObservable instead of events

两盒软妹~` 提交于 2019-12-21 09:30:08
问题 I've recently been reading about IObservable. So far, i've looked at various SO questions, and watched a video on what they can do. The whole "push" mechanism I'm thinking is brilliant, but I'm still trying to figure out what exactly everything does. From my readings, I guess in a way an IObservable is something that can be 'watched', and IObservers are the 'watchers'. So now I'm off to try and implement this in my application. There are a few things I would like to nut out before I get

Rx operator to distinct sequences

折月煮酒 提交于 2019-12-21 09:12:11
问题 IMPORTANT : for a description of the results and some more details, please have a look also to my answer I need to group and filter a sequence of objects/events that usually are replicated, buffering them with a TimeSpan interval. I try to explain it better with sort of marble diagrams: X-X-X-X-X-Y-Y-Y-Z-Z-Z-Z-X-X-Y-Z-Z would produce X---Y---Z---X---Y---Z where X, Y and Z are different event types, and '---' means the interval. Additionally, I would also like to distinct by a key property

IObservable<> missing .Subscribe extension methods

浪尽此生 提交于 2019-12-21 07:31:22
问题 I'm using RX extensions and WF4 to create a workflow which reacts to observable messages to progress the workflow. To do this, I bring in an object containing an IObservable (ModuleMessage being my abstract class.) The problem I'm having is that .Subscribe fails to recognize any of its extension methods, namely the one for lambda extpressions/method groups. In the following code, I have references: using System.Activities; using System.Activities.Hosting; using System.Collections.Generic;