Inherits from RACSignal : RACStream : NSObject
Declared in RACDynamicSignal.h
RACDynamicSignal.m

Tasks

Other Methods

Other Methods

Class Methods

createSignal:

Creates a new signal. This is the preferred way to create a new signal operation or behavior.

+ (RACSignal *)createSignal:(RACDisposable *( ^ ) ( id<RACSubscriber> subscriber ))didSubscribe

Discussion

Events can be sent to new subscribers immediately in the didSubscribe block, but the subscriber will not be able to dispose of the signal until a RACDisposable is returned from didSubscribe. In the case of infinite signals, this won’t ever happen if events are sent immediately.

To ensure that the signal is disposable, events can be scheduled on the [RACScheduler currentScheduler] (so that they’re deferred, not sent immediately), or they can be sent in the background. The RACDisposable returned by the didSubscribe block should cancel any such scheduling or asynchronous work.

didSubscribe - Called when the signal is subscribed to. The new subscriber is passed in. You can then manually control the RACSubscriber by sending it -sendNext:, -sendError:, and -sendCompleted, as defined by the operation you’re implementing. This block should return a RACDisposable which cancels any ongoing work triggered by the subscription, and cleans up any resources or disposables created as part of it. When the disposable is disposed of, the signal must not send any more events to the subscriber. If no cleanup is necessary, return nil.

Note: The didSubscribe block is called every time a new subscriber subscribes. Any side effects within the block will thus execute once for each subscription, not necessarily on one thread, and possibly even simultaneously!

Declared In

RACSignal.h

Instance Methods

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