-1

In reactive programming, cold observable starts emitting values only when observers have subscribed to it.

I have a question in this context.

Suppose I subscribe S1 on observable O at time T1, and hence S1 starts receiving values.Then I subscribe S2 on O at time T2.

Would S2 receive values emitted by O between T1 and T2?

Mandroid
  • 6,200
  • 12
  • 64
  • 134

1 Answers1

0

The short answer is that S2 would receive values only from time T2.

There are several operators you can use that will replay emitted values. You can use a combination of replay(), publish(), refCount(), etc, to allow replaying values between T1 and T2. Here is a good overview of cold versus hot observables.

Bob Dalgleish
  • 8,167
  • 4
  • 32
  • 42