I want to create if/else construction by Reactive Cocoa.
I have the code :
In that construction called rac_testYES
signal, but it's something strange because if:[RACSignal return:@0]
returnNO
.
Why call rac_testYES
method?
This code works as expected.
If you change the if statement to [RACSignal return:@1]
then YES
will be printed.
EDITED
The both methods are called because they are just a parameters for [RACSignal if:then:else:]
method.
ReactivCocoa will call subscribeNext/subscribeComplited for the provided signal according to if if
signal return YES
or NO
.
So if you wan do sth for YES:
-(RACSignal)rac_testYES {
return [RACSignal createSignal:^RACDisposable *(id <RACSubscriber> subscriber) {
//do sth
[subscriber sendNext:@"YES"];
[subscriber sendComplited];
}
}