Skip to content

Instantly share code, notes, and snippets.

@erikprice
Created November 17, 2013 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikprice/7517146 to your computer and use it in GitHub Desktop.
Save erikprice/7517146 to your computer and use it in GitHub Desktop.
Test to verify that in a RACSignal subscription chain, the completed event on a signal downstream of a `+merge:` invokes the disposable of an upstream signal. (ReactiveCocoa)
it(@"should propagate disposal to signals upstream of a +merge: to which it is subscribed when it completes", ^{
__block BOOL disposed1 = NO;
__block BOOL disposed2 = NO;
RACSignal *upstream1 = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> _) {
return [RACDisposable disposableWithBlock:^{
disposed1 = YES;
}];
}];
RACSignal *upstream2 = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> _) {
return [RACDisposable disposableWithBlock:^{
disposed2 = YES;
}];
}];
RACSubject *trigger = [RACSubject subject];
RACSignal *merged = [RACSignal merge:@[upstream1, upstream2]];
RACSignal *downstream = [merged takeUntil:trigger];
[downstream subscribeNext:^(id _) { }];
expect(disposed1).to.beFalsy();
expect(disposed2).to.beFalsy();
[trigger sendNext:RACUnit.defaultUnit];
expect(disposed1).to.beTruthy();
expect(disposed2).to.beTruthy();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment