Skip to content

Commit 5406a55

Browse files
authored
Merge pull request ReactiveCocoa#32 from Lightricks/feature/racdisposable-subscribe-nullable
RACSignal: annotate -subscribe: methods to return nullable disposable.
2 parents df047e1 + b004385 commit 5406a55

10 files changed

+24
-24
lines changed

ReactiveObjC/RACBehaviorSubject.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ + (instancetype)behaviorSubjectWithDefaultValue:(id)value {
2929

3030
#pragma mark RACSignal
3131

32-
- (RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
32+
- (nullable RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
3333
RACDisposable *subscriptionDisposable = [super subscribe:subscriber];
3434

3535
RACDisposable *schedulingDisposable = [RACScheduler.subscriptionScheduler schedule:^{

ReactiveObjC/RACChannel.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ - (instancetype)initWithValues:(RACSignal *)values otherTerminal:(id<RACSubscrib
6363

6464
#pragma mark RACSignal
6565

66-
- (RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
66+
- (nullable RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
6767
return [self.values subscribe:subscriber];
6868
}
6969

ReactiveObjC/RACDynamicSignal.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ + (RACSignal *)createSignal:(RACDisposable * (^)(id<RACSubscriber> subscriber))d
3333

3434
#pragma mark Managing Subscribers
3535

36-
- (RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
36+
- (nullable RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
3737
NSCParameterAssert(subscriber != nil);
3838

3939
RACCompoundDisposable *disposable = [RACCompoundDisposable compoundDisposable];

ReactiveObjC/RACEmptySignal.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ + (RACSignal *)empty {
5151

5252
#pragma mark Subscription
5353

54-
- (RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
54+
- (nullable RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
5555
NSCParameterAssert(subscriber != nil);
5656

5757
return [RACScheduler.subscriptionScheduler schedule:^{

ReactiveObjC/RACErrorSignal.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ + (RACSignal *)error:(NSError *)error {
3636

3737
#pragma mark Subscription
3838

39-
- (RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
39+
- (nullable RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
4040
NSCParameterAssert(subscriber != nil);
4141

4242
return [RACScheduler.subscriptionScheduler schedule:^{

ReactiveObjC/RACReplaySubject.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ - (instancetype)initWithCapacity:(NSUInteger)capacity {
5151

5252
#pragma mark RACSignal
5353

54-
- (RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
54+
- (nullable RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
5555
RACCompoundDisposable *compoundDisposable = [RACCompoundDisposable compoundDisposable];
5656

5757
RACDisposable *schedulingDisposable = [RACScheduler.subscriptionScheduler schedule:^{

ReactiveObjC/RACReturnSignal.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ + (RACSignal *)return:(id)value {
7878

7979
#pragma mark Subscription
8080

81-
- (RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
81+
- (nullable RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
8282
NSCParameterAssert(subscriber != nil);
8383

8484
return [RACScheduler.subscriptionScheduler schedule:^{

ReactiveObjC/RACSignal.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -394,34 +394,34 @@ typedef RACSignal * _Nullable (^RACSignalBindBlock)(ValueType _Nullable value, B
394394
/// need to end your subscription before it would "naturally" end, either by
395395
/// completing or erroring. Once the disposable has been disposed, the subscriber
396396
/// won't receive any more events from the subscription.
397-
- (RACDisposable *)subscribe:(id<RACSubscriber>)subscriber;
397+
- (nullable RACDisposable *)subscribe:(id<RACSubscriber>)subscriber;
398398

399399
/// Convenience method to subscribe to the `next` event.
400400
///
401401
/// This corresponds to `IObserver<T>.OnNext` in Rx.
402-
- (RACDisposable *)subscribeNext:(void (^)(ValueType _Nullable x))nextBlock;
402+
- (nullable RACDisposable *)subscribeNext:(void (^)(ValueType _Nullable x))nextBlock;
403403

404404
/// Convenience method to subscribe to the `next` and `completed` events.
405-
- (RACDisposable *)subscribeNext:(void (^)(ValueType _Nullable x))nextBlock completed:(void (^)(void))completedBlock;
405+
- (nullable RACDisposable *)subscribeNext:(void (^)(ValueType _Nullable x))nextBlock completed:(void (^)(void))completedBlock;
406406

407407
/// Convenience method to subscribe to the `next`, `completed`, and `error` events.
408-
- (RACDisposable *)subscribeNext:(void (^)(ValueType _Nullable x))nextBlock error:(void (^)(NSError * _Nullable error))errorBlock completed:(void (^)(void))completedBlock;
408+
- (nullable RACDisposable *)subscribeNext:(void (^)(ValueType _Nullable x))nextBlock error:(void (^)(NSError * _Nullable error))errorBlock completed:(void (^)(void))completedBlock;
409409

410410
/// Convenience method to subscribe to `error` events.
411411
///
412412
/// This corresponds to the `IObserver<T>.OnError` in Rx.
413-
- (RACDisposable *)subscribeError:(void (^)(NSError * _Nullable error))errorBlock;
413+
- (nullable RACDisposable *)subscribeError:(void (^)(NSError * _Nullable error))errorBlock;
414414

415415
/// Convenience method to subscribe to `completed` events.
416416
///
417417
/// This corresponds to the `IObserver<T>.OnCompleted` in Rx.
418-
- (RACDisposable *)subscribeCompleted:(void (^)(void))completedBlock;
418+
- (nullable RACDisposable *)subscribeCompleted:(void (^)(void))completedBlock;
419419

420420
/// Convenience method to subscribe to `next` and `error` events.
421-
- (RACDisposable *)subscribeNext:(void (^)(ValueType _Nullable x))nextBlock error:(void (^)(NSError * _Nullable error))errorBlock;
421+
- (nullable RACDisposable *)subscribeNext:(void (^)(ValueType _Nullable x))nextBlock error:(void (^)(NSError * _Nullable error))errorBlock;
422422

423423
/// Convenience method to subscribe to `error` and `completed` events.
424-
- (RACDisposable *)subscribeError:(void (^)(NSError * _Nullable error))errorBlock completed:(void (^)(void))completedBlock;
424+
- (nullable RACDisposable *)subscribeError:(void (^)(NSError * _Nullable error))errorBlock completed:(void (^)(void))completedBlock;
425425

426426
@end
427427

ReactiveObjC/RACSignal.m

+8-8
Original file line numberDiff line numberDiff line change
@@ -556,27 +556,27 @@ - (instancetype)skipUntilBlock:(BOOL (^)(id x))predicate {
556556

557557
@implementation RACSignal (Subscription)
558558

559-
- (RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
559+
- (nullable RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
560560
NSCAssert(NO, @"This method must be overridden by subclasses");
561561
return nil;
562562
}
563563

564-
- (RACDisposable *)subscribeNext:(void (^)(id x))nextBlock {
564+
- (nullable RACDisposable *)subscribeNext:(void (^)(id x))nextBlock {
565565
NSCParameterAssert(nextBlock != NULL);
566566

567567
RACSubscriber *o = [RACSubscriber subscriberWithNext:nextBlock error:NULL completed:NULL];
568568
return [self subscribe:o];
569569
}
570570

571-
- (RACDisposable *)subscribeNext:(void (^)(id x))nextBlock completed:(void (^)(void))completedBlock {
571+
- (nullable RACDisposable *)subscribeNext:(void (^)(id x))nextBlock completed:(void (^)(void))completedBlock {
572572
NSCParameterAssert(nextBlock != NULL);
573573
NSCParameterAssert(completedBlock != NULL);
574574

575575
RACSubscriber *o = [RACSubscriber subscriberWithNext:nextBlock error:NULL completed:completedBlock];
576576
return [self subscribe:o];
577577
}
578578

579-
- (RACDisposable *)subscribeNext:(void (^)(id x))nextBlock error:(void (^)(NSError *error))errorBlock completed:(void (^)(void))completedBlock {
579+
- (nullable RACDisposable *)subscribeNext:(void (^)(id x))nextBlock error:(void (^)(NSError *error))errorBlock completed:(void (^)(void))completedBlock {
580580
NSCParameterAssert(nextBlock != NULL);
581581
NSCParameterAssert(errorBlock != NULL);
582582
NSCParameterAssert(completedBlock != NULL);
@@ -585,29 +585,29 @@ - (RACDisposable *)subscribeNext:(void (^)(id x))nextBlock error:(void (^)(NSErr
585585
return [self subscribe:o];
586586
}
587587

588-
- (RACDisposable *)subscribeError:(void (^)(NSError *error))errorBlock {
588+
- (nullable RACDisposable *)subscribeError:(void (^)(NSError *error))errorBlock {
589589
NSCParameterAssert(errorBlock != NULL);
590590

591591
RACSubscriber *o = [RACSubscriber subscriberWithNext:NULL error:errorBlock completed:NULL];
592592
return [self subscribe:o];
593593
}
594594

595-
- (RACDisposable *)subscribeCompleted:(void (^)(void))completedBlock {
595+
- (nullable RACDisposable *)subscribeCompleted:(void (^)(void))completedBlock {
596596
NSCParameterAssert(completedBlock != NULL);
597597

598598
RACSubscriber *o = [RACSubscriber subscriberWithNext:NULL error:NULL completed:completedBlock];
599599
return [self subscribe:o];
600600
}
601601

602-
- (RACDisposable *)subscribeNext:(void (^)(id x))nextBlock error:(void (^)(NSError *error))errorBlock {
602+
- (nullable RACDisposable *)subscribeNext:(void (^)(id x))nextBlock error:(void (^)(NSError *error))errorBlock {
603603
NSCParameterAssert(nextBlock != NULL);
604604
NSCParameterAssert(errorBlock != NULL);
605605

606606
RACSubscriber *o = [RACSubscriber subscriberWithNext:nextBlock error:errorBlock completed:NULL];
607607
return [self subscribe:o];
608608
}
609609

610-
- (RACDisposable *)subscribeError:(void (^)(NSError *))errorBlock completed:(void (^)(void))completedBlock {
610+
- (nullable RACDisposable *)subscribeError:(void (^)(NSError *))errorBlock completed:(void (^)(void))completedBlock {
611611
NSCParameterAssert(completedBlock != NULL);
612612
NSCParameterAssert(errorBlock != NULL);
613613

ReactiveObjC/RACSubject.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ - (void)dealloc {
5151

5252
#pragma mark Subscription
5353

54-
- (RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
54+
- (nullable RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
5555
NSCParameterAssert(subscriber != nil);
5656

5757
RACCompoundDisposable *disposable = [RACCompoundDisposable compoundDisposable];

0 commit comments

Comments
 (0)