Maybe I'm totally missing this but according to the documentation on ReactiveCocoa on their types, RACSequences are signals.
However. I see examples where you have code like this:
RACSignal *letters = [@"A B C D E F G H I" componentsSeparatedByString:@" "].rac_sequence.signal;
// Outputs: A B C D E F G H I
[letters subscribeNext:^(NSString *x) {
NSLog(@"%@", x);
}];
And also
RACSequence *letters = [@"A B C D E F G H I" componentsSeparatedByString:@" "].rac_sequence;
// Contains: AA BB CC DD EE FF GG HH II
RACSequence *mapped = [letters map:^(NSString *value) {
return [value stringByAppendingString:value];
}];
A lot of the examples have RACSequence and RACSignal. What's the difference between rac_sequence.signal or just subscribing to the signal itself?
One is pull driven (RACSequence
) and the other is push driven (RACSignal
). From here:
Push-driven means that values for the signal are not defined at the moment of signal creation and may become available at a later time (for example, as a result from network request, or any user input). Pull-driven means that values in the sequence are defined at the moment of signal creation and we can query values from the stream one-by-one.
In your case, you make the RACSignal
pull-driven, because you are already have its values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With