Rx Challenge #6 Solution


the previous challenge was about weakening the reference to the subscriber. you can see the challenge here. my solution for this challenge involve WeakObserver class + extension method which will create mediator of the weak observer each subscription. the following code snippet describe my solution: public class WeakObserver<T> : IObserver<T>{ private readonly WeakReference<IObserver<T>> _target; #region Ctor /// <summary> /// Initializes a new instance of the <see cref="WeakObserver{T}"/> class. /// </summary> /// <param name="target">The target.</param> /// <exception cref="System.ArgumentNullException">target</exception>...
no comments

Rx Challenge #6


this challenge come from Rx Forum question which ask about Weak subscription to observable. as the case with event, the observable is holding reference to its' subscription. when the observer life-time shouldn't dictate by the life-time of the observable, you need to weaken the reference to observer and let the GC to collect it while the only rooted reference to the observer come from its' subscription.   your challenge is to build this functionality. the next code snippet will help you to validate your solution: public void WeakSubscription_Test(){ // re-process a value when the...
no comments

Rx Challenge #5 Solution

Challenge #5 was about fault tolerance you can check the challenge details in here. the solution composed of Replay(1) and Retry() operations, but keep in mind that Replay return connectable observable, therefore it should come with Connect or RefCount (you can read more about it in here) you can also check out this Rx Forum's thread from where the original question was asked.   so without further ado, the code snippet below is my suggestion for the challenge's solution. public void FaultTolleranceAnswer1_Test(){ // re-process a value when the stream ahead produce error ...
no comments

Rx Challenge #5


this challenge come right from a question on the RX's forum. by checking the forum's thread you will find the answer to this challenge but you may want to solve it by yourself, before getting a backed answer.   this challenge is about fault tolerance in RX, RX is having a few fault handling operators but in general, when those operator triggered they only handling re-subscription to the original or fallback stream. this challenge is to have safe-point where RX's composition can re-process a value from this point in case of failure. it resemble to Spark capability of...
no comments

Rx Challenge #4 (More Solutions)


My colleague Eric Rabinovitch was offering different yet elegant solution for Rx Challenge #4 which I want to share with you. his approach includes window + aggregation. you can check the following code, which provided by Eric. // device provides stream of byte that represent message header + body// for each byte the first byte represent the header// the first byte represent Message Type Enum of (None, MessageA, MessageB, C)// while the real message may be construct from multiple sequence of byte// when the first byte != None the 2nd byte represent the number of byte used //...
no comments