I couldn't find much documentation about RAC then
operator. What is the purpose it serves. When should I use. it? Can someone explain in below context?
[[[[self requestAccessToTwitterSignal]
then:^RACSignal *{
@strongify(self)
return self.searchText.rac_textSignal;
}]
filter:^BOOL(NSString *text) {
@strongify(self)
return [self isValidSearchText:text];
}]
subscribeNext:^(id x) {
NSLog(@"%@", x);
} error:^(NSError *error) {
NSLog(@"An error occurred: %@", error);
}];
The code documentation provide a sound explanation.
/// Ignores all `next`s from the receiver, waits for the receiver to complete,
/// then subscribes to a new signal.
///
/// block - A block which will create or obtain a new signal to subscribe to,
/// executed only after the receiver completes. This block must not be
/// nil, and it must not return a nil signal.
///
/// Returns a signal which will pass through the events of the signal created in
/// `block`. If the receiver errors out, the returned signal will error as well.
So in your context. it waits until requestAccessToTwitterSignal complete. Ignores any event after that. And then
subscribes to the new signal. Which is self.searchText.rac_textSignal
. The filter
applies to the new signal.