Harry
Harry

Reputation: 3116

ReactiveCocoa: Immediately send the latest value when there's a new subscription

I have a bunch of manual RACSubject properties in a particular view model; I am calling sendNext at certain points in the code, and I want new subscribers to these signals to immediately have their subscribeNext block be called with the latest value in that signal. Is this possible?

As an example, if I am sending the values 1 -> 12 -> 42 and then down the line there's a new subscriber, I want that subscriber to get 42 straight off (and then obviously listen for more pushes when they come about).

Upvotes: 0

Views: 182

Answers (1)

Harry
Harry

Reputation: 3116

OK so it looks like I wanted to be using the RACSubject subclass RACReplaySubject instead. Not sure how I missed that one!

Upvotes: 3

Related Questions