Using ReactiveCocoa, there seem to be two ways to have subscribers receive the same values from a signal, rather than re-triggering whatever operation generates those values: Via RACReplaySubject or RACMulticastConnection.
Here are the header docs for RACReplaySubject:
A replay subject saves the values it is sent (up to its defined capacity) and resends those to new subscribers. It will also replay an error or completion.
And for RACMulticastConnection:
A multicast connection encapsulates the idea of sharing one subscription to a signal to many subscribers. This is most often needed if the subscription to the underlying signal involves side-effects or shouldn't be called more than once.
The multicasted signal is only subscribed to when
-[RACMulticastConnection connect]
is called. Until that happens, no values will be sent onsignal
. See-[RACMulticastConnection autoconnect]
for how-[RACMulticastConnection connect]
can be called automatically.Note that you shouldn't create RACMulticastConnection manually. Instead use
-[RACSignal publish]
or-[RACSignal multicast:]
.
Can someone provide simple guidelines as to when you would use RACReplaySubject or RACMulticastConnection?