This is my code snippet. The issue is it doesn't reach subscribeCompleted block. It supposed to immediately complete as I return empty signal inside flattenmap block. Isn't it?
RACObserve(self.object, "mobile").skip(2).doNext { (_) -> Void in
self.tabBarController?.showHud("Updating Profile")
}.flattenMap { (object) -> RACStream! in
return RACSignal.empty()
}.subscribeCompleted { () -> Void in
log.error("Completed")
self.tabBarController?.hideHud()
}
The signal returned by
flattenMapwill complete only when the "source" signal completes. In your case you applyflattenMapoperator to the following signal:RACObserve(self.object, "mobile").skip(2)The signal returned by
RACObservecompletes only when the object being observed is deallocated. Depending on what you want to achieve, you can use some operators to transform the signal and get another one that will complete earlier.For example, you can use
filterandtakeso that the resulting signal completes after sending its first value matching some conditions:Note that you don't even need
flattenMapat all. The signal will simply complete because oftakeoperator.