File tree Expand file tree Collapse file tree 3 files changed +19
-8
lines changed Expand file tree Collapse file tree 3 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ extern const NSInteger RACSignalErrorNoMatchingCase;
125
125
// / of the receiver.
126
126
- (RACSignal<ValueType> *)initially : (void (^)(void ))block RAC_WARN_UNUSED_RESULT;
127
127
128
- // / Executes the given block when the signal completes or errors .
128
+ // / Executes the given block when the signal completes, errs or the subscription is disposed .
129
129
- (RACSignal<ValueType> *)finally : (void (^)(void ))block RAC_WARN_UNUSED_RESULT;
130
130
131
131
// / Divides the receiver's `next`s into buffers which deliver every `interval`
Original file line number Diff line number Diff line change @@ -313,14 +313,20 @@ - (RACSignal *)initially:(void (^)(void))block {
313
313
- (RACSignal *)finally : (void (^)(void ))block {
314
314
NSCParameterAssert (block != NULL );
315
315
316
- return [[[self
317
- doError: ^(NSError *error) {
318
- block ();
319
- }]
320
- doCompleted: ^{
316
+ return [[RACSignal createSignal: ^RACDisposable *(id <RACSubscriber> subscriber) {
317
+ RACDisposable *selfDisposable = [self subscribeNext: ^(id x) {
318
+ [subscriber sendNext: x];
319
+ } error: ^(NSError *error) {
320
+ [subscriber sendError: error];
321
+ } completed: ^{
322
+ [subscriber sendCompleted ];
323
+ }];
324
+
325
+ return [RACDisposable disposableWithBlock: ^{
321
326
block ();
322
- }]
323
- setNameWithFormat: @" [%@ ] -finally:" , self .name];
327
+ [selfDisposable dispose ];
328
+ }];
329
+ }] setNameWithFormat: @" [%@ ] -finally:" , self .name];
324
330
}
325
331
326
332
- (RACSignal *)bufferWithTime : (NSTimeInterval )interval onScheduler : (RACScheduler *)scheduler {
Original file line number Diff line number Diff line change @@ -3762,6 +3762,11 @@ + (void)configure:(Configuration *)configuration {
3762
3762
[subject sendError: nil ];
3763
3763
expect (@(finallyInvoked)).to (beTruthy ());
3764
3764
});
3765
+
3766
+ qck_it (@" should run finally upon disposal" , ^{
3767
+ [disposable dispose ];
3768
+ expect (@(finallyInvoked)).to (beTruthy ());
3769
+ });
3765
3770
});
3766
3771
});
3767
3772
You can’t perform that action at this time.
0 commit comments