Group Group Group Group Group Group Group Group Group

Chapter 18: Custom Publishers & Backpressure

I couldn’t figure out this, in the ShareReplay Publisher(Transformer to be more precise) when I finished I’ve got this output:

shareReplay: receive subscription: (PassthroughSubject)
shareReplay: request unlimited
shareReplay: receive value: (1)
+0.04658s: subscription1 received 1
shareReplay: receive value: (2)
+0.04791s: subscription1 received 2
shareReplay: receive value: (3)
+0.04878s: subscription1 received 3
+0.05000s: subscription2 received 2
+0.05009s: subscription2 received 3
shareReplay: receive value: (4)
+0.05055s: subscription1 received 4
+0.05080s: subscription2 received 4
shareReplay: receive value: (5)
+0.05166s: subscription1 received 5
+0.05192s: subscription2 received 5
shareReplay: receive finished
+0.05359s: subscription1 completed: finished
+0.05383s: subscription2 completed: finished
Subscribing to shareReplay after upstream completed
+1.05626s: subscription3 received 4
+1.05640s: subscription3 received 5
+1.05695s: subscription3 completed: finished

1. Why didn’t the subscription 2 get value 1, and subscription 3 get 1,2,3. Even if I set the capacity to 20, it will support all values of the example(we just sent 5 values through the subject).

2. We never delete data from our replay variable inside the ShareReplay class, so when a new subscription is created we pass this array to it and there when that receives a new input from upstream we can send the values inside the buffer variable(ShareReplaySubscription) + the new value. I don’t get, why are there some values not delivered to the the subscription(just the first is the only one that gets all)?.

Is it possible to explain in a detailed way?