For example:
In one controller, implementation
func sendSuccessOrNot()->RACSignal {
// code here
}
In another controller, calling that signal
controller.sendSuccessOrNot().subscribeNext {
}
how to check in the above calling if sendSuccessOrNot is sending error or success value in ReactiveCocoa.
The syntax you use makes me think you're using Swift, in which case you shouldn't be using RACSignal, you should be converting your RACSignal to a SignalProducer with .toSignalProducer()
func sendSuccessOrNot() -> RACSignal {
return RACSignal.createSignal { (subscriber) -> RACDisposable! in
let test = true
if (test) {
subscriber.sendNext("Value")
subscriber.sendCompleted()
} else {
subscriber.sendError(NSError(domain: "", code: 0, userInfo: nil))
}
return RACDisposable(block: {})
}
}
controller.sendSuccessOrNot().toSignalProducer().on(next: { value in
print("next: \(value)")
},
failed: { error in
print("failed: \(error)")
}).start()
If you're still using RAC 2 then it'd be
controller.sendSuccessOrNot().subscribeNext({ value in
print("next: \(value)")
}, error: { error in
print("failed: \(error)")
})