1

I have created a app using reactive cocoa signals. In my app I have created some RacSignals and then merged the signals into a single signal and subscribed to it. Now if User logs out, I want a way to cancel all the signals that I have merged. Is there a way to cancel all active RacSignals in a single go? or cancelling the merged signal will cancel all the signals merged to it.

user3168555
  • 81
  • 1
  • 4

2 Answers2

1

check this issue on GitHub.

So you can do sth. like this:

RACDisposable *disposable = [[RACSignal combineLatest:@[signal1,signal2]]
                              subscribeError:^(NSError *error) {}];

and when you want to cancel:

[disposable dispose];
Mateusz
  • 1,222
  • 11
  • 22
0

Mateusz is right but I have a feeling you're not entirely sure what the semantics of disposing a RACDisposable are. So here goes:

In the example of Mateusz only the subscription is cancelled (disposed of), but the signal lives on (as long as it is not dealloced of course).

A RACSignal lives on even if there are no subscriptions to it, and it can potentially continue sending next values as long as it is not ended by an error or a complete event.

If by "Cancelling" a signal you mean stop subscribing to the next values, then disposing the disposable is the way to go. If "Cancelling" means completing the signal then have a look at the takeUntil: method, which completes the returning signal at your convenience (this will still not complete the original signal however)

Hope that helped a bit

Nicolai Dahl
  • 259
  • 3
  • 9