Rx Challenge #8 Solution


this post is part of series, the hole series can be found in here. this challenge was all about buffering the data on suspension period and flush it out on resume. the idea is to suspend the observable notification for a while without loosing data. the following diagram show the required functionality Marble Diagram /************************************************* * source  ---1---2---3---4---5---6---7---8---9---10---11-| * hold    -------------T-----------F-----------T---------| * result  ---1---2---3-------------4567--8---9-----------10,11-| *************************************************/ solving this problem require some kind of buffering and if you follow my blog you must know that when it come to buffer and dispatch I’m usually integrating...
no comments

Rx Challenge #8


this post is part of series, the hole series can be found in here.   this challenge is all about buffering data while suspended and flush it out on resume. we already had challenge on Suspend and Resume but that challenge ignored the data during the suspension period. on this challenge you expected to buffer the data during the suspension period and flush it out on resume. to achieve this challenge you have to provide extension method on the following format: Code Snippet public static IObservable<T> HoldWhile<T>(             this IObservable<T> source,             IObservable<bool> hold) {     /*************************************************...
no comments

Challenge Quick Access (Links)


this is a quick access page to the Challenges Challenge #1: Buffer On Time, Count and Custom Trigger  http://blogs.microsoft.co.il/bnaya/2015/01/27/rx-challenge/ #2: Avoid Overlaps http://blogs.microsoft.co.il/bnaya/2015/02/05/rx-challenge-2/ #3: Suspend on faults throttle http://blogs.microsoft.co.il/bnaya/2015/03/06/rx-challenge-3/ #4: Create message from spitted chunks http://blogs.microsoft.co.il/bnaya/2015/03/25/rx-challenge-4/ #5: Exception Safe-Point http://blogs.microsoft.co.il/bnaya/2015/04/03/rx-challenge-5/ #6: Weak subscription  http://blogs.microsoft.co.il/bnaya/2015/04/10/rx-challenge-6/ #7: Where Async http://blogs.microsoft.co.il/bnaya/2015/07/11/rx-challenge-7/ #8: Suspend Buffering and flush http://blogs.microsoft.co.il/bnaya/2015/07/24/rx-challenge-8/ #9: Execute Async Until http://blogs.microsoft.co.il/bnaya/2016/08/16/rx-challenge-9-execute-async-until/ #10: DistinctUntilChanged with expiration period http://blogs.microsoft.co.il/bnaya/2016/08/19/rx-challenge-10-distinctuntilchanged-with-expiration-period/ #11: Semaphore Wait Async Like http://blogs.microsoft.co.il/bnaya/2016/09/08/rx-challenge-11/ #12: Task.Delay http://blogs.microsoft.co.il/bnaya/2017/04/14/task-delay-challenge/   Solutions #1: Buffer On Time, Count and Custom Trigger http://blogs.microsoft.co.il/bnaya/2015/01/31/rx-challenge-solution/ #2: Avoid Overlaps  http://blogs.microsoft.co.il/bnaya/2015/02/09/rx-challenge-2-solution/...

Rx Challenge #7 Solution

the last challenge was about extending Rx API to support WhereAsync. while following Rx guidelines to ensure keeping events in order and synchronized “Assume observer instances are called in a serialized fashion” page 8, synchronization of async events may not be so trivial, solving it may require message buffering and dispatching. with that in mind, you can either build custom buffering and dispatching component or use existing one like TPL Dataflow. it turn out that this is exactly what TPL Dataflow design for. more than that, TPL Dataflow integrate smoothly with Rx .   the following solution is...
one comment

Rx Challenge #7


this challenge is all about extending the Rx API to support WhereAsync let take the following scenario: var xs = Observable.Interval(TimeSpan.FromMinutes(1)); what if you’re having the following method which get long and return Task<bool> Code Snippet public async Task<bool> IsValidAsync(long value) {     // in real life the method may send     // the to a service and get whether it's     // ok to use it     await Task.Delay(1000);     return value % 2 == 0; } can you filter the observable using this method? the problem...
one comment