Inherits from RACSignal : RACStream : NSObject
Conforms to RACSubscriber
Declared in RACSubject.h
RACSubject.m

Overview

A subject can be thought of as a signal that you can manually control by sending next, completed, and error.

They’re most helpful in bridging the non-RAC world to RAC, since they let you manually control the sending of events.

Class Methods

subject

Returns a new subject.

+ (instancetype)subject

Declared In

RACSubject.h

Instance Methods

didSubscribeWithDisposable:

Sends the subscriber a disposable that represents one of its subscriptions.

- (void)didSubscribeWithDisposable:(RACDisposable *)d

Discussion

A subscriber may receive multiple disposables if it gets subscribed to multiple signals; however, any error or completed events must terminate all subscriptions.

Declared In

RACSubscriber.h

sendCompleted

Send completed to subscribers.

- (void)sendCompleted

Discussion

This terminates the subscription, and invalidates the subscriber (such that it cannot subscribe to anything else in the future).

Declared In

RACSubscriber.h

sendError:

Send the error to subscribers.

- (void)sendError:(NSError *)error

Discussion

error - The error to send. This can be nil.

This terminates the subscription, and invalidates the subscriber (such that it cannot subscribe to anything else in the future).

Declared In

RACSubscriber.h

sendNext:

Send the next value to subscribers.

- (void)sendNext:(id)value

Discussion

value - The value to send. This can be nil.

Declared In

RACSubscriber.h

subscribe:

Subscribes subscriber to changes on the receiver. The receiver defines which events it actually sends and in what situations the events are sent.

- (RACDisposable *)subscribe:(id<RACSubscriber>)subscriber

Discussion

Subscription will always happen on a valid RACScheduler. If the [RACScheduler currentScheduler] cannot be determined at the time of subscription (e.g., because the calling code is running on a GCD queue or NSOperationQueue), subscription will occur on a private background scheduler. On the main thread, subscriptions will always occur immediately, with a [RACScheduler currentScheduler] of [RACScheduler mainThreadScheduler].

This method must be overridden by any subclasses.

Returns nil or a disposable. You can call [RACDisposable dispose] if you need to end your subscription before it would “naturally” end, either by completing or erroring. Once the disposable has been disposed, the subscriber won’t receive any more events from the subscription.

Declared In

RACSignal.h