Created
November 17, 2013 19:28
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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