Inherits from RACStream : NSObject
Declared in RACSignal.h

Overview

Additional methods to assist with debugging. The error code used when a value passed into switch:cases:default: does not match any of the cases, and no default was given. Additional methods to assist with unit testing.

These methods should never ship in production code.

Tasks

Other Methods

Deprecated Methods

RACStream Methods

  • + return:

    Returns a signal that immediately sends the given value and then completes.

  • + empty

    Returns a signal that immediately completes.

  • – concat:

    Subscribes to signal when the source signal completes.

  • – zipWith:

    Zips the values in the receiver with those of the given signal to create RACTuples.

Debugging Methods

Operations Methods

  • – doNext:

    Do the given block on next. This should be used to inject side effects into the signal.

  • – doError:

    Do the given block on error. This should be used to inject side effects into the signal.

  • – doCompleted:

    Do the given block on completed. This should be used to inject side effects into the signal.

  • – throttle:

    Send nexts only if we don’t receive another next in interval seconds.

  • – throttle:valuesPassingTest:

    Throttles nexts for which predicate returns YES.

  • – delay:

    Forwards next and completed events after delaying for interval seconds on the current scheduler (on which the events were delivered).

  • – repeat

    Resubscribes when the signal completes.

  • – initially:

    Execute the given block each time a subscription is created.

  • – finally:

    Execute the given block when the signal completes or errors.

  • – bufferWithTime:onScheduler:

    Divides the receiver’s nexts into buffers which deliver every interval seconds.

  • – collect

    Collect all receiver’s nexts into a NSArray. nil values will be converted to NSNull.

  • – takeLast:

    Takes the last count nexts after the receiving signal completes.

  • – combineLatestWith:

    Combines the latest values from the receiver and the given signal into RACTuples, once both have sent at least one next.

  • + combineLatest:

    Combines the latest values from the given signals into RACTuples, once all the signals have sent at least one next.

  • + combineLatest:reduce:

    Combines signals using combineLatest:, then reduces the resulting tuples into a single value using -reduceEach:.

  • + merge:

    Sends the latest next from any of the signals.

  • – flatten:

    Merges the signals sent by the receiver into a flattened signal, but only subscribes to maxConcurrent number of signals at a time. New signals are queued and subscribed to as other signals complete.

  • – then:

    Ignores all nexts from the receiver, waits for the receiver to complete, then subscribes to a new signal.

  • – concat

    Concats the inner signals of a signal of signals.

  • – aggregateWithStart:reduce:

    Aggregate nexts with the given start and combination.

  • – aggregateWithStartFactory:reduce:

    Aggregate nexts with the given start and combination. The start factory block is called to get a new start object for each subscription.

  • – setKeyPath:onObject:

    Invokes setKeyPath:onObject:nilValue: with nil for the nil value.

  • – setKeyPath:onObject:nilValue:

    Binds the receiver to an object, automatically setting the given key path on every next. When the signal completes, the binding is automatically disposed of.

  • + interval:onScheduler:

    Sends NSDate.date every interval seconds.

  • + interval:onScheduler:withLeeway:

    Sends NSDate.date at intervals of at least interval seconds, up to approximately interval + leeway seconds.

  • – takeUntil:

    Take nexts until the signalTrigger sends next or completed.

  • – takeUntilReplacement:

    Take nexts until the replacement sends an event.

  • – catch:

    Subscribe to the returned signal when an error occurs.

  • – catchTo:

    Subscribe to the given signal when an error occurs.

  • – try:

    Runs tryBlock against each of the receiver’s values, passing values until tryBlock returns NO, or the receiver completes.

  • – tryMap:

    Runs mapBlock against each of the receiver’s values, mapping values until mapBlock returns nil, or the receiver completes.

  • – first

    Returns the first next. Note that this is a blocking call.

  • – firstOrDefault:

    Returns the first next or defaultValue if the signal completes or errors without sending a next. Note that this is a blocking call.

  • – firstOrDefault:success:error:

    Returns the first next or defaultValue if the signal completes or errors without sending a next. If an error occurs success will be NO and error will be populated. Note that this is a blocking call.

  • – waitUntilCompleted:

    Blocks the caller and waits for the signal to complete.

  • + defer:

    Defer creation of a signal until the signal’s actually subscribed to.

  • – switchToLatest

    Every time the receiver sends a new RACSignal, subscribes and sends nexts and errors only for that signal.

  • + switch:cases:default:

    Switches between the signals in cases as well as defaultSignal based on the latest value sent by signal.

  • + if:then:else:

    Switches between trueSignal and falseSignal based on the latest value sent by boolSignal.

  • – toArray

    Add every next to an array. Nils are represented by NSNulls. Note that this is a blocking call.

  •   sequence

    Add every next to a sequence. Nils are represented by NSNulls.

    property
  • – publish

    Creates and returns a multicast connection. This allows you to share a single subscription to the underlying signal.

  • – multicast:

    Creates and returns a multicast connection that pushes values into the given subject. This allows you to share a single subscription to the underlying signal.

  • – replay

    Multicasts the signal to a RACReplaySubject of unlimited capacity, and immediately connects to the resulting RACMulticastConnection.

  • – replayLast

    Multicasts the signal to a RACReplaySubject of capacity 1, and immediately connects to the resulting RACMulticastConnection.

  • – replayLazily

    Multicasts the signal to a RACReplaySubject of unlimited capacity, and lazily connects to the resulting RACMulticastConnection.

  • – timeout:onScheduler:

    Sends an error after interval seconds if the source doesn’t complete before then.

  • – deliverOn:

    Creates and returns a signal that delivers its events on the given scheduler. Any side effects of the receiver will still be performed on the original thread.

  • – subscribeOn:

    Creates and returns a signal that executes its side effects and delivers its events on the given scheduler.

  • – groupBy:transform:

    Groups each received object into a group, as determined by calling keyBlock with that object. The object sent is transformed by calling transformBlock with the object. If transformBlock is nil, it sends the original object.

  • – groupBy:

    Calls -[RACSignal groupBy:keyBlock transform:nil].

  • – any

    Sends an [NSNumber numberWithBool:YES] if the receiving signal sends any objects.

  • – any:

    Sends an [NSNumber numberWithBool:YES] if the receiving signal sends any objects that pass predicateBlock.

  • – all:

    Sends an [NSNumber numberWithBool:YES] if all the objects the receiving signal sends pass predicateBlock.

  • – retry:

    Resubscribes to the receiving signal if an error occurs, up until it has retried the given number of times.

  • – retry

    Resubscribes to the receiving signal if an error occurs.

  • – sample:

    Sends the latest value from the receiver only when sampler sends a value. The returned signal could repeat values if sampler fires more often than the receiver. Values from sampler are ignored before the receiver sends its first value.

  • – ignoreValues

    Ignores all nexts from the receiver.

  • – materialize

    Converts each of the receiver’s events into a RACEvent object.

  • – dematerialize

    Converts each RACEvent in the receiver back into “real” RACSignal events.

  • – not

    Inverts each NSNumber-wrapped BOOL sent by the receiver. It will assert if the receiver sends anything other than NSNumbers.

  • – and

    Performs a boolean AND on all of the RACTuple of NSNumbers in sent by the receiver.

  • – or

    Performs a boolean OR on all of the RACTuple of NSNumbers in sent by the receiver.

OperationsDeprecated Methods

Subscription Methods

Testing Methods

Properties

sequence

Add every next to a sequence. Nils are represented by NSNulls.

@property (nonatomic, strong, readonly) RACSequence *sequence

Discussion

Add every next to a sequence. Nils are represented by NSNulls.

This corresponds to the ToEnumerable method in Rx.

Returns a sequence which provides values from the signal as they’re sent. Trying to retrieve a value from the sequence which has not yet been sent will block.

Declared In

RACSignal+Operations.h

Class Methods

combineLatest:

Combines the latest values from the given signals into RACTuples, once all the signals have sent at least one next.

+ (RACSignal *)combineLatest:(id<NSFastEnumeration>)signals

Discussion

Combines the latest values from the given signals into RACTuples, once all the signals have sent at least one next.

Any additional nexts will result in a new RACTuple with the latest values from all signals.

signals - The signals to combine. If this collection is empty, the returned signal will immediately complete upon subscription.

Returns a signal which sends RACTuples of the combined values, forwards any error events, and completes when all input signals complete.

Declared In

RACSignal+Operations.h

combineLatest:reduce:

Combines signals using combineLatest:, then reduces the resulting tuples into a single value using -reduceEach:.

+ (RACSignal *)combineLatest:(id<NSFastEnumeration>)signals reduce:(id ( ^ ) ( ))reduceBlock

Discussion

Combines signals using combineLatest:, then reduces the resulting tuples into a single value using -reduceEach:.

signals - The signals to combine. If this collection is empty, the returned signal will immediately complete upon subscription. reduceBlock - The block which reduces the latest values from all the signals into one value. It must take as many arguments as the number of signals given. Each argument will be an object argument. The return value must be an object. This argument must not be nil.

Example:

[RACSignal combineLatest:@[ stringSignal, intSignal ] reduce:^(NSString string, NSNumber number) { return [NSString stringWithFormat:@“%@: %@”, string, number]; }];

Returns a signal which sends the results from each invocation of reduceBlock.

Declared In

RACSignal+Operations.h

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

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

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

defer:

Defer creation of a signal until the signal’s actually subscribed to.

+ (RACSignal *)defer:(RACSignal *( ^ ) ( void ))block

Discussion

Defer creation of a signal until the signal’s actually subscribed to.

This can be used to effectively turn a hot signal into a cold signal.

Declared In

RACSignal+Operations.h

empty

Returns a signal that immediately completes.

+ (RACSignal *)empty

Discussion

Returns a signal that immediately completes.

Declared In

RACSignal.h

error:

Returns a signal that immediately sends the given error.

+ (RACSignal *)error:(NSError *)error

Discussion

Returns a signal that immediately sends the given error.

Declared In

RACSignal.h

if:then:else:

Switches between trueSignal and falseSignal based on the latest value sent by boolSignal.

+ (RACSignal *)if:(RACSignal *)boolSignal then:(RACSignal *)trueSignal else:(RACSignal *)falseSignal

Discussion

Switches between trueSignal and falseSignal based on the latest value sent by boolSignal.

boolSignal - A signal of BOOLs determining whether trueSignal or falseSignal should be active. This argument must not be nil. trueSignal - The signal to pass through after boolSignal has sent YES. This argument must not be nil. falseSignal - The signal to pass through after boolSignal has sent NO. This argument must not be nil.

Returns a signal which passes through nexts and errors from trueSignal and/or falseSignal, and sends completed when both boolSignal and the last switched signal complete.

Declared In

RACSignal+Operations.h

interval:

+ (RACSignal *)interval:(NSTimeInterval)interval

interval:onScheduler:

Sends NSDate.date every interval seconds.

+ (RACSignal *)interval:(NSTimeInterval)interval onScheduler:(RACScheduler *)scheduler

Discussion

Sends NSDate.date every interval seconds.

interval - The time interval in seconds at which the current time is sent. scheduler - The scheduler upon which the current NSDate should be sent. This must not be nil or [RACScheduler immediateScheduler].

Returns a signal that sends the current date/time every interval on scheduler.

Declared In

RACSignal+Operations.h

interval:onScheduler:withLeeway:

Sends NSDate.date at intervals of at least interval seconds, up to approximately interval + leeway seconds.

+ (RACSignal *)interval:(NSTimeInterval)interval onScheduler:(RACScheduler *)scheduler withLeeway:(NSTimeInterval)leeway

Discussion

Sends NSDate.date at intervals of at least interval seconds, up to approximately interval + leeway seconds.

The created signal will defer sending each next for at least interval seconds, and for an additional amount of time up to leeway seconds in the interest of performance or power consumption. Note that some additional latency is to be expected, even when specifying a leeway of 0.

interval - The base interval between nexts. scheduler - The scheduler upon which the current NSDate should be sent. This must not be nil or [RACScheduler immediateScheduler]. leeway - The maximum amount of additional time the next can be deferred.

Returns a signal that sends the current date/time at intervals of at least interval seconds up to approximately interval + leeway seconds on scheduler.

Declared In

RACSignal+Operations.h

interval:withLeeway:

+ (RACSignal *)interval:(NSTimeInterval)interval withLeeway:(NSTimeInterval)leeway

merge:

Sends the latest next from any of the signals.

+ (RACSignal *)merge:(id<NSFastEnumeration>)signals

Discussion

Sends the latest next from any of the signals.

Returns a signal that passes through values from each of the given signals, and sends completed when all of them complete. If any signal sends an error, the returned signal sends error immediately.

Declared In

RACSignal+Operations.h

never

Returns a signal that never completes.

+ (RACSignal *)never

Discussion

Returns a signal that never completes.

Declared In

RACSignal.h

return:

Returns a signal that immediately sends the given value and then completes.

+ (RACSignal *)return:(id)value

Discussion

Returns a signal that immediately sends the given value and then completes.

Declared In

RACSignal.h

start:

+ (RACSignal *)start:(id ( ^ ) ( BOOL *success , NSError **error ))block

startEagerlyWithScheduler:block:

Immediately schedules the given block on the given scheduler. The block is given a subscriber to which it can send events.

+ (RACSignal *)startEagerlyWithScheduler:(RACScheduler *)scheduler block:(void ( ^ ) ( id<RACSubscriber> subscriber ))block

Discussion

Immediately schedules the given block on the given scheduler. The block is given a subscriber to which it can send events.

scheduler - The scheduler on which block will be scheduled and results delivered. Cannot be nil. block - The block to invoke. Cannot be NULL.

Returns a signal which will send all events sent on the subscriber given to block. All events will be sent on scheduler and it will replay any missed events to new subscribers.

Declared In

RACSignal.h

startLazilyWithScheduler:block:

Invokes the given block only on the first subscription. The block is given a subscriber to which it can send events.

+ (RACSignal *)startLazilyWithScheduler:(RACScheduler *)scheduler block:(void ( ^ ) ( id<RACSubscriber> subscriber ))block

Discussion

Invokes the given block only on the first subscription. The block is given a subscriber to which it can send events.

Note that disposing of the subscription to the returned signal will not dispose of the underlying subscription. If you need that behavior, see [RACMulticastConnection autoconnect]. The underlying subscription will never be disposed of. Because of this, block should never return an infinite signal since there would be no way of ending it.

scheduler - The scheduler on which the block should be scheduled. Note that if given [RACScheduler immediateScheduler], the block will be invoked synchronously on the first subscription. Cannot be nil. block - The block to invoke on the first subscription. Cannot be NULL.

Returns a signal which will pass through the events sent to the subscriber given to block and replay any missed events to new subscribers.

Declared In

RACSignal.h

startWithScheduler:block:

+ (RACSignal *)startWithScheduler:(RACScheduler *)scheduler block:(id ( ^ ) ( BOOL *success , NSError **error ))block

startWithScheduler:subjectBlock:

+ (RACSignal *)startWithScheduler:(RACScheduler *)scheduler subjectBlock:(void ( ^ ) ( RACSubject *subject ))block

switch:cases:default:

Switches between the signals in cases as well as defaultSignal based on the latest value sent by signal.

+ (RACSignal *)switch:(RACSignal *)signal cases:(NSDictionary *)cases default:(RACSignal *)defaultSignal

Discussion

Switches between the signals in cases as well as defaultSignal based on the latest value sent by signal.

signal - A signal of objects used as keys in the cases dictionary. This argument must not be nil. cases - A dictionary that has signals as values. This argument must not be nil. A RACTupleNil key in this dictionary will match nil next events that are received on signal. defaultSignal - The signal to pass through after signal sends a value for which cases does not contain a signal. If nil, any unmatched values will result in a RACSignalErrorNoMatchingCase error.

Returns a signal which passes through nexts and errors from one of the the signals in cases or defaultSignal, and sends completed when both signal and the last used signal complete. If no defaultSignal is given, an unmatched next will result in an error on the returned signal.

Declared In

RACSignal+Operations.h

Instance Methods

aggregateWithStart:combine:

- (RACSignal *)aggregateWithStart:(id)start combine:(id ( ^ ) ( id running , id next ))combineBlock

aggregateWithStart:reduce:

Aggregate nexts with the given start and combination.

- (RACSignal *)aggregateWithStart:(id)start reduce:(id ( ^ ) ( id running , id next ))reduceBlock

Discussion

Aggregate nexts with the given start and combination.

Declared In

RACSignal+Operations.h

aggregateWithStartFactory:combine:

- (RACSignal *)aggregateWithStartFactory:(id ( ^ ) ( void ))startFactory combine:(id ( ^ ) ( id running , id next ))combineBlock

aggregateWithStartFactory:reduce:

Aggregate nexts with the given start and combination. The start factory block is called to get a new start object for each subscription.

- (RACSignal *)aggregateWithStartFactory:(id ( ^ ) ( void ))startFactory reduce:(id ( ^ ) ( id running , id next ))reduceBlock

Discussion

Aggregate nexts with the given start and combination. The start factory block is called to get a new start object for each subscription.

Declared In

RACSignal+Operations.h

all:

Sends an [NSNumber numberWithBool:YES] if all the objects the receiving signal sends pass predicateBlock.

- (RACSignal *)all:(BOOL ( ^ ) ( id object ))predicateBlock

Discussion

Sends an [NSNumber numberWithBool:YES] if all the objects the receiving signal sends pass predicateBlock.

predicateBlock - cannot be nil.

Declared In

RACSignal+Operations.h

and

Performs a boolean AND on all of the RACTuple of NSNumbers in sent by the receiver.

- (RACSignal *)and

Discussion

Performs a boolean AND on all of the RACTuple of NSNumbers in sent by the receiver.

Asserts if the receiver sends anything other than a RACTuple of one or more NSNumbers.

Returns a signal that applies AND to each NSNumber in the tuple.

Declared In

RACSignal+Operations.h

any

Sends an [NSNumber numberWithBool:YES] if the receiving signal sends any objects.

- (RACSignal *)any

Discussion

Sends an [NSNumber numberWithBool:YES] if the receiving signal sends any objects.

Declared In

RACSignal+Operations.h

any:

Sends an [NSNumber numberWithBool:YES] if the receiving signal sends any objects that pass predicateBlock.

- (RACSignal *)any:(BOOL ( ^ ) ( id object ))predicateBlock

Discussion

Sends an [NSNumber numberWithBool:YES] if the receiving signal sends any objects that pass predicateBlock.

predicateBlock - cannot be nil.

Declared In

RACSignal+Operations.h

asynchronousFirstOrDefault:success:error:

Spins the main run loop for a short while, waiting for the receiver to send a next.

- (id)asynchronousFirstOrDefault:(id)defaultValue success:(BOOL *)success error:(NSError **)error

Discussion

Spins the main run loop for a short while, waiting for the receiver to send a next.

Because this method executes the run loop recursively, it should only be used on the main thread, and only from a unit test.

defaultValue - Returned if the receiver completes or errors before sending a next, or if the method times out. This argument may be nil. success - If not NULL, set to whether the receiver completed successfully. error - If not NULL, set to any error that occurred.

Returns the first value received, or defaultValue if no value is received before the signal finishes or the method times out.

Declared In

RACSignal.h

asynchronouslyWaitUntilCompleted:

Spins the main run loop for a short while, waiting for the receiver to complete.

- (BOOL)asynchronouslyWaitUntilCompleted:(NSError **)error

Discussion

Spins the main run loop for a short while, waiting for the receiver to complete.

Because this method executes the run loop recursively, it should only be used on the main thread, and only from a unit test.

error - If not NULL, set to any error that occurs.

Returns whether the signal completed successfully before timing out. If NO, error will be set to any error that occurred.

Declared In

RACSignal.h

buffer:

- (RACSignal *)buffer:(NSUInteger)bufferCount

bufferWithTime:

- (RACSignal *)bufferWithTime:(NSTimeInterval)interval

bufferWithTime:onScheduler:

Divides the receiver’s nexts into buffers which deliver every interval seconds.

- (RACSignal *)bufferWithTime:(NSTimeInterval)interval onScheduler:(RACScheduler *)scheduler

Discussion

Divides the receiver’s nexts into buffers which deliver every interval seconds.

interval - The interval in which values are grouped into one buffer. scheduler - The scheduler upon which the returned signal will deliver its values. This must not be nil or [RACScheduler immediateScheduler].

Returns a signal which sends RACTuples of the buffered values at each interval on scheduler. When the receiver completes, any currently-buffered values will be sent immediately.

Declared In

RACSignal+Operations.h

catch:

Subscribe to the returned signal when an error occurs.

- (RACSignal *)catch:(RACSignal *( ^ ) ( NSError *error ))catchBlock

Discussion

Subscribe to the returned signal when an error occurs.

Declared In

RACSignal+Operations.h

catchTo:

Subscribe to the given signal when an error occurs.

- (RACSignal *)catchTo:(RACSignal *)signal

Discussion

Subscribe to the given signal when an error occurs.

Declared In

RACSignal+Operations.h

collect

Collect all receiver’s nexts into a NSArray. nil values will be converted to NSNull.

- (RACSignal *)collect

Discussion

Collect all receiver’s nexts into a NSArray. nil values will be converted to NSNull.

This corresponds to the ToArray method in Rx.

Returns a signal which sends a single NSArray when the receiver completes successfully.

Declared In

RACSignal+Operations.h

combineLatestWith:

Combines the latest values from the receiver and the given signal into RACTuples, once both have sent at least one next.

- (RACSignal *)combineLatestWith:(RACSignal *)signal

Discussion

Combines the latest values from the receiver and the given signal into RACTuples, once both have sent at least one next.

Any additional nexts will result in a new RACTuple with the latest values from both signals.

signal - The signal to combine with. This argument must not be nil.

Returns a signal which sends RACTuples of the combined values, forwards any error events, and completes when both input signals complete.

Declared In

RACSignal+Operations.h

concat

Concats the inner signals of a signal of signals.

- (RACSignal *)concat

Discussion

Concats the inner signals of a signal of signals.

Declared In

RACSignal+Operations.h

concat:

Subscribes to signal when the source signal completes.

- (RACSignal *)concat:(RACSignal *)signal

Discussion

Subscribes to signal when the source signal completes.

Declared In

RACSignal.h

delay:

Forwards next and completed events after delaying for interval seconds on the current scheduler (on which the events were delivered).

- (RACSignal *)delay:(NSTimeInterval)interval

Discussion

Forwards next and completed events after delaying for interval seconds on the current scheduler (on which the events were delivered).

If [RACScheduler currentScheduler] is nil when next or completed is received, a private background scheduler is used.

Returns a signal which sends delayed next and completed events. Errors are always forwarded immediately.

Declared In

RACSignal+Operations.h

deliverOn:

Creates and returns a signal that delivers its events on the given scheduler. Any side effects of the receiver will still be performed on the original thread.

- (RACSignal *)deliverOn:(RACScheduler *)scheduler

Discussion

Creates and returns a signal that delivers its events on the given scheduler. Any side effects of the receiver will still be performed on the original thread.

This is ideal when the signal already performs its work on the desired thread, but you want to handle its events elsewhere.

This corresponds to the ObserveOn method in Rx.

Declared In

RACSignal+Operations.h

dematerialize

Converts each RACEvent in the receiver back into “real” RACSignal events.

- (RACSignal *)dematerialize

Discussion

Converts each RACEvent in the receiver back into “real” RACSignal events.

Returns a signal which sends next for each value RACEvent, error for each error RACEvent, and completed for each completed RACEvent.

Declared In

RACSignal+Operations.h

doCompleted:

Do the given block on completed. This should be used to inject side effects into the signal.

- (RACSignal *)doCompleted:(void ( ^ ) ( void ))block

Discussion

Do the given block on completed. This should be used to inject side effects into the signal.

Declared In

RACSignal+Operations.h

doError:

Do the given block on error. This should be used to inject side effects into the signal.

- (RACSignal *)doError:(void ( ^ ) ( NSError *error ))block

Discussion

Do the given block on error. This should be used to inject side effects into the signal.

Declared In

RACSignal+Operations.h

doNext:

Do the given block on next. This should be used to inject side effects into the signal.

- (RACSignal *)doNext:(void ( ^ ) ( id x ))block

Discussion

Do the given block on next. This should be used to inject side effects into the signal.

Declared In

RACSignal+Operations.h

executeCommand:

- (RACDisposable *)executeCommand:(RACCommand *)command

finally:

Execute the given block when the signal completes or errors.

- (RACSignal *)finally:(void ( ^ ) ( void ))block

Discussion

Execute the given block when the signal completes or errors.

Declared In

RACSignal+Operations.h

first

Returns the first next. Note that this is a blocking call.

- (id)first

Discussion

Returns the first next. Note that this is a blocking call.

Declared In

RACSignal+Operations.h

firstOrDefault:

Returns the first next or defaultValue if the signal completes or errors without sending a next. Note that this is a blocking call.

- (id)firstOrDefault:(id)defaultValue

Discussion

Returns the first next or defaultValue if the signal completes or errors without sending a next. Note that this is a blocking call.

Declared In

RACSignal+Operations.h

firstOrDefault:success:error:

Returns the first next or defaultValue if the signal completes or errors without sending a next. If an error occurs success will be NO and error will be populated. Note that this is a blocking call.

- (id)firstOrDefault:(id)defaultValue success:(BOOL *)success error:(NSError **)error

Discussion

Returns the first next or defaultValue if the signal completes or errors without sending a next. If an error occurs success will be NO and error will be populated. Note that this is a blocking call.

Both success and error may be NULL.

Declared In

RACSignal+Operations.h

flatten:

Merges the signals sent by the receiver into a flattened signal, but only subscribes to maxConcurrent number of signals at a time. New signals are queued and subscribed to as other signals complete.

- (RACSignal *)flatten:(NSUInteger)maxConcurrent

Discussion

Merges the signals sent by the receiver into a flattened signal, but only subscribes to maxConcurrent number of signals at a time. New signals are queued and subscribed to as other signals complete.

If an error occurs on any of the signals, it is sent on the returned signal. It completes only after the receiver and all sent signals have completed.

This corresponds to Merge<TSource>(IObservable<IObservable<TSource>>, Int32) in Rx.

maxConcurrent - the maximum number of signals to subscribe to at a time. If 0, it subscribes to an unlimited number of signals.

Declared In

RACSignal+Operations.h

groupBy:

Calls -[RACSignal groupBy:keyBlock transform:nil].

- (RACSignal *)groupBy:(id<NSCopying> ( ^ ) ( id object ))keyBlock

Discussion

Calls -[RACSignal groupBy:keyBlock transform:nil].

Declared In

RACSignal+Operations.h

groupBy:transform:

Groups each received object into a group, as determined by calling keyBlock with that object. The object sent is transformed by calling transformBlock with the object. If transformBlock is nil, it sends the original object.

- (RACSignal *)groupBy:(id<NSCopying> ( ^ ) ( id object ))keyBlock transform:(id ( ^ ) ( id object ))transformBlock

Discussion

Groups each received object into a group, as determined by calling keyBlock with that object. The object sent is transformed by calling transformBlock with the object. If transformBlock is nil, it sends the original object.

The returned signal is a signal of RACGroupedSignal.

Declared In

RACSignal+Operations.h

ignoreElements

- (RACSignal *)ignoreElements

ignoreValues

Ignores all nexts from the receiver.

- (RACSignal *)ignoreValues

Discussion

Ignores all nexts from the receiver.

Returns a signal which only passes through error or completed events from the receiver.

Declared In

RACSignal+Operations.h

initially:

Execute the given block each time a subscription is created.

- (RACSignal *)initially:(void ( ^ ) ( void ))block

Discussion

Execute the given block each time a subscription is created.

block - A block which defines the subscription side effects. Cannot be nil.

Example:

// Write new file, with backup. [[[[fileManager rac_createFileAtPath:path contents:data] initially:^{ // 2. Second, backup current file [fileManager moveItemAtPath:path toPath:backupPath error:nil]; }] initially:^{ // 1. First, acquire write lock. [writeLock lock]; }] finally:^{ [writeLock unlock]; }];

Returns a signal that passes through all events of the receiver, plus introduces side effects which occur prior to any subscription side effects of the receiver.

Declared In

RACSignal+Operations.h

let:

- (RACSignal *)let:(RACSignal *( ^ ) ( RACSignal *sharedSignal ))letBlock

logAll

Logs all events that the receiver sends.

- (RACSignal *)logAll

Discussion

Logs all events that the receiver sends.

Declared In

RACSignal.h

logCompleted

Logs any completed event that the receiver sends.

- (RACSignal *)logCompleted

Discussion

Logs any completed event that the receiver sends.

Declared In

RACSignal.h

logError

Logs any error that the receiver sends.

- (RACSignal *)logError

Discussion

Logs any error that the receiver sends.

Declared In

RACSignal.h

logNext

Logs each next that the receiver sends.

- (RACSignal *)logNext

Discussion

Logs each next that the receiver sends.

Declared In

RACSignal.h

materialize

Converts each of the receiver’s events into a RACEvent object.

- (RACSignal *)materialize

Discussion

Converts each of the receiver’s events into a RACEvent object.

Returns a signal which sends the receiver’s events as RACEvents, and completes after the receiver sends completed or error.

Declared In

RACSignal+Operations.h

multicast:

Creates and returns a multicast connection that pushes values into the given subject. This allows you to share a single subscription to the underlying signal.

- (RACMulticastConnection *)multicast:(RACSubject *)subject

Discussion

Creates and returns a multicast connection that pushes values into the given subject. This allows you to share a single subscription to the underlying signal.

Declared In

RACSignal+Operations.h

not

Inverts each NSNumber-wrapped BOOL sent by the receiver. It will assert if the receiver sends anything other than NSNumbers.

- (RACSignal *)not

Discussion

Inverts each NSNumber-wrapped BOOL sent by the receiver. It will assert if the receiver sends anything other than NSNumbers.

Returns a signal of inverted NSNumber-wrapped BOOLs.

Declared In

RACSignal+Operations.h

or

Performs a boolean OR on all of the RACTuple of NSNumbers in sent by the receiver.

- (RACSignal *)or

Discussion

Performs a boolean OR on all of the RACTuple of NSNumbers in sent by the receiver.

Asserts if the receiver sends anything other than a RACTuple of one or more NSNumbers.

Returns a signal that applies OR to each NSNumber in the tuple.

Declared In

RACSignal+Operations.h

publish

Creates and returns a multicast connection. This allows you to share a single subscription to the underlying signal.

- (RACMulticastConnection *)publish

Discussion

Creates and returns a multicast connection. This allows you to share a single subscription to the underlying signal.

Declared In

RACSignal+Operations.h

repeat

Resubscribes when the signal completes.

- (RACSignal *)repeat

Discussion

Resubscribes when the signal completes.

Declared In

RACSignal+Operations.h

replay

Multicasts the signal to a RACReplaySubject of unlimited capacity, and immediately connects to the resulting RACMulticastConnection.

- (RACSignal *)replay

Discussion

Multicasts the signal to a RACReplaySubject of unlimited capacity, and immediately connects to the resulting RACMulticastConnection.

Returns the connected, multicasted signal.

Declared In

RACSignal+Operations.h

replayLast

Multicasts the signal to a RACReplaySubject of capacity 1, and immediately connects to the resulting RACMulticastConnection.

- (RACSignal *)replayLast

Discussion

Multicasts the signal to a RACReplaySubject of capacity 1, and immediately connects to the resulting RACMulticastConnection.

Returns the connected, multicasted signal.

Declared In

RACSignal+Operations.h

replayLazily

Multicasts the signal to a RACReplaySubject of unlimited capacity, and lazily connects to the resulting RACMulticastConnection.

- (RACSignal *)replayLazily

Discussion

Multicasts the signal to a RACReplaySubject of unlimited capacity, and lazily connects to the resulting RACMulticastConnection.

This means the returned signal will subscribe to the multicasted signal only when the former receives its first subscription.

Returns the lazily connected, multicasted signal.

Declared In

RACSignal+Operations.h

retry

Resubscribes to the receiving signal if an error occurs.

- (RACSignal *)retry

Discussion

Resubscribes to the receiving signal if an error occurs.

Declared In

RACSignal+Operations.h

retry:

Resubscribes to the receiving signal if an error occurs, up until it has retried the given number of times.

- (RACSignal *)retry:(NSInteger)retryCount

Discussion

Resubscribes to the receiving signal if an error occurs, up until it has retried the given number of times.

retryCount - if 0, it keeps retrying until it completes.

Declared In

RACSignal+Operations.h

sample:

Sends the latest value from the receiver only when sampler sends a value. The returned signal could repeat values if sampler fires more often than the receiver. Values from sampler are ignored before the receiver sends its first value.

- (RACSignal *)sample:(RACSignal *)sampler

Discussion

Sends the latest value from the receiver only when sampler sends a value. The returned signal could repeat values if sampler fires more often than the receiver. Values from sampler are ignored before the receiver sends its first value.

sampler - The signal that controls when the latest value from the receiver is sent. Cannot be nil.

Declared In

RACSignal+Operations.h

sequenceNext:

- (RACSignal *)sequenceNext:(RACSignal *( ^ ) ( void ))block

setKeyPath:onObject:

Invokes setKeyPath:onObject:nilValue: with nil for the nil value.

- (RACDisposable *)setKeyPath:(NSString *)keyPath onObject:(NSObject *)object

Discussion

Invokes setKeyPath:onObject:nilValue: with nil for the nil value.

Declared In

RACSignal+Operations.h

setKeyPath:onObject:nilValue:

Binds the receiver to an object, automatically setting the given key path on every next. When the signal completes, the binding is automatically disposed of.

- (RACDisposable *)setKeyPath:(NSString *)keyPath onObject:(NSObject *)object nilValue:(id)nilValue

Discussion

Binds the receiver to an object, automatically setting the given key path on every next. When the signal completes, the binding is automatically disposed of.

Sending an error on the signal is considered undefined behavior, and will generate an assertion failure in Debug builds.

A given key on an object should only have one active signal bound to it at any given time. Binding more than one signal to the same property is considered undefined behavior.

keyPath - The key path to update with nexts from the receiver. object - The object that keyPath is relative to. nilValue - The value to set at the key path whenever nil is sent by the receiver. This may be nil when binding to object properties, but an NSValue should be used for primitive properties, to avoid an exception if nil is sent (which might occur if an intermediate object is set to nil).

Returns a disposable which can be used to terminate the binding.

Declared In

RACSignal+Operations.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

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

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

subscribeCompleted:

Convenience method to subscribe to completed events.

- (RACDisposable *)subscribeCompleted:(void ( ^ ) ( void ))completedBlock

Discussion

Convenience method to subscribe to completed events.

This corresponds to the IObserver<T>.OnCompleted in Rx.

Declared In

RACSignal.h

subscribeError:

Convenience method to subscribe to error events.

- (RACDisposable *)subscribeError:(void ( ^ ) ( NSError *error ))errorBlock

Discussion

Convenience method to subscribe to error events.

This corresponds to the IObserver<T>.OnError in Rx.

Declared In

RACSignal.h

subscribeError:completed:

Convenience method to subscribe to error and completed events.

- (RACDisposable *)subscribeError:(void ( ^ ) ( NSError *error ))errorBlock completed:(void ( ^ ) ( void ))completedBlock

Discussion

Convenience method to subscribe to error and completed events.

Declared In

RACSignal.h

subscribeNext:

Convenience method to subscribe to the next event.

- (RACDisposable *)subscribeNext:(void ( ^ ) ( id x ))nextBlock

Discussion

Convenience method to subscribe to the next event.

This corresponds to IObserver<T>.OnNext in Rx.

Declared In

RACSignal.h

subscribeNext:completed:

Convenience method to subscribe to the next and completed events.

- (RACDisposable *)subscribeNext:(void ( ^ ) ( id x ))nextBlock completed:(void ( ^ ) ( void ))completedBlock

Discussion

Convenience method to subscribe to the next and completed events.

Declared In

RACSignal.h

subscribeNext:error:

Convenience method to subscribe to next and error events.

- (RACDisposable *)subscribeNext:(void ( ^ ) ( id x ))nextBlock error:(void ( ^ ) ( NSError *error ))errorBlock

Discussion

Convenience method to subscribe to next and error events.

Declared In

RACSignal.h

subscribeNext:error:completed:

Convenience method to subscribe to the next, completed, and error events.

- (RACDisposable *)subscribeNext:(void ( ^ ) ( id x ))nextBlock error:(void ( ^ ) ( NSError *error ))errorBlock completed:(void ( ^ ) ( void ))completedBlock

Discussion

Convenience method to subscribe to the next, completed, and error events.

Declared In

RACSignal.h

subscribeOn:

Creates and returns a signal that executes its side effects and delivers its events on the given scheduler.

- (RACSignal *)subscribeOn:(RACScheduler *)scheduler

Discussion

Creates and returns a signal that executes its side effects and delivers its events on the given scheduler.

Use of this operator should be avoided whenever possible, because the receiver’s side effects may not be safe to run on another thread. If you just want to receive the signal’s events on scheduler, use deliverOn: instead.

Declared In

RACSignal+Operations.h

switchToLatest

Every time the receiver sends a new RACSignal, subscribes and sends nexts and errors only for that signal.

- (RACSignal *)switchToLatest

Discussion

Every time the receiver sends a new RACSignal, subscribes and sends nexts and errors only for that signal.

The receiver must be a signal of signals.

Returns a signal which passes through nexts and errors from the latest signal sent by the receiver, and sends completed when both the receiver and the last sent signal complete.

Declared In

RACSignal+Operations.h

takeLast:

Takes the last count nexts after the receiving signal completes.

- (RACSignal *)takeLast:(NSUInteger)count

Discussion

Takes the last count nexts after the receiving signal completes.

Declared In

RACSignal+Operations.h

takeUntil:

Take nexts until the signalTrigger sends next or completed.

- (RACSignal *)takeUntil:(RACSignal *)signalTrigger

Discussion

Take nexts until the signalTrigger sends next or completed.

Returns a signal which passes through all events from the receiver until signalTrigger sends next or completed, at which point the returned signal will send completed.

Declared In

RACSignal+Operations.h

takeUntilReplacement:

Take nexts until the replacement sends an event.

- (RACSignal *)takeUntilReplacement:(RACSignal *)replacement

Discussion

Take nexts until the replacement sends an event.

replacement - The signal which replaces the receiver as soon as it sends an event.

Returns a signal which passes through nexts and error from the receiver until replacement sends an event, at which point the returned signal will send that event and switch to passing through events from replacement instead, regardless of whether the receiver has sent events already.

Declared In

RACSignal+Operations.h

then:

Ignores all nexts from the receiver, waits for the receiver to complete, then subscribes to a new signal.

- (RACSignal *)then:(RACSignal *( ^ ) ( void ))block

Discussion

Ignores all nexts from the receiver, waits for the receiver to complete, then subscribes to a new signal.

block - A block which will create or obtain a new signal to subscribe to, executed only after the receiver completes. This block must not be nil, and it must not return a nil signal.

Returns a signal which will pass through the events of the signal created in block. If the receiver errors out, the returned signal will error as well.

Declared In

RACSignal+Operations.h

throttle:

Send nexts only if we don’t receive another next in interval seconds.

- (RACSignal *)throttle:(NSTimeInterval)interval

Discussion

Send nexts only if we don’t receive another next in interval seconds.

If a next is received, and then another next is received before interval seconds have passed, the first value is discarded.

After interval seconds have passed since the most recent next was sent, the most recent next is forwarded on the scheduler that the value was originally received on. If [RACScheduler currentScheduler] was nil at the time, a private background scheduler is used.

Returns a signal which sends throttled and delayed next events. Completion and errors are always forwarded immediately.

Declared In

RACSignal+Operations.h

throttle:valuesPassingTest:

Throttles nexts for which predicate returns YES.

- (RACSignal *)throttle:(NSTimeInterval)interval valuesPassingTest:(BOOL ( ^ ) ( id next ))predicate

Discussion

Throttles nexts for which predicate returns YES.

When predicate returns YES for a next:

  1. If another next is received before interval seconds have passed, the prior value is discarded. This happens regardless of whether the new value will be throttled.
  2. After interval seconds have passed since the value was originally received, it will be forwarded on the scheduler that it was received upon. If [RACScheduler currentScheduler] was nil at the time, a private background scheduler is used.

When predicate returns NO for a next, it is forwarded immediately, without any throttling.

interval - The number of seconds for which to buffer the latest value that passes predicate. predicate - Passed each next from the receiver, this block returns whether the given value should be throttled. This argument must not be nil.

Returns a signal which sends next events, throttled when predicate returns YES. Completion and errors are always forwarded immediately.

Declared In

RACSignal+Operations.h

timeout:

- (RACSignal *)timeout:(NSTimeInterval)interval

timeout:onScheduler:

Sends an error after interval seconds if the source doesn’t complete before then.

- (RACSignal *)timeout:(NSTimeInterval)interval onScheduler:(RACScheduler *)scheduler

Discussion

Sends an error after interval seconds if the source doesn’t complete before then.

The error will be in the RACSignalErrorDomain and have a code of RACSignalErrorTimedOut.

interval - The number of seconds after which the signal should error out. scheduler - The scheduler upon which any timeout error should be sent. This must not be nil or [RACScheduler immediateScheduler].

Returns a signal that passes through the receiver’s events, until the stream finishes or times out, at which point an error will be sent on scheduler.

Declared In

RACSignal+Operations.h

toArray

Add every next to an array. Nils are represented by NSNulls. Note that this is a blocking call.

- (NSArray *)toArray

Discussion

Add every next to an array. Nils are represented by NSNulls. Note that this is a blocking call.

This is not the same as the ToArray method in Rx. See collect for that behavior instead.

Returns the array of next values, or nil if an error occurs.

Declared In

RACSignal+Operations.h

toProperty:onObject:

- (RACDisposable *)toProperty:(NSString *)keyPath onObject:(NSObject *)object

try:

Runs tryBlock against each of the receiver’s values, passing values until tryBlock returns NO, or the receiver completes.

- (RACSignal *)try:(BOOL ( ^ ) ( id value , NSError **errorPtr ))tryBlock

Discussion

Runs tryBlock against each of the receiver’s values, passing values until tryBlock returns NO, or the receiver completes.

tryBlock - An action to run against each of the receiver’s values. The block should return YES to indicate that the action was successful. This block must not be nil.

Example:

// The returned signal will send an error if data values cannot be // written to someFileURL. [signal try:^(NSData *data, NSError **errorPtr) { return [data writeToURL:someFileURL options:NSDataWritingAtomic error:errorPtr]; }];

Returns a signal which passes through all the values of the receiver. If tryBlock fails for any value, the returned signal will error using the NSError passed out from the block.

Declared In

RACSignal+Operations.h

tryMap:

Runs mapBlock against each of the receiver’s values, mapping values until mapBlock returns nil, or the receiver completes.

- (RACSignal *)tryMap:(id ( ^ ) ( id value , NSError **errorPtr ))mapBlock

Discussion

Runs mapBlock against each of the receiver’s values, mapping values until mapBlock returns nil, or the receiver completes.

mapBlock - An action to map each of the receiver’s values. The block should return a non-nil value to indicate that the action was successful. This block must not be nil.

Example:

// The returned signal will send an error if data cannot be read from // fileURL. [signal tryMap:^(NSURL *fileURL, NSError **errorPtr) { return [NSData dataWithContentsOfURL:fileURL options:0 error:errorPtr]; }];

Returns a signal which transforms all the values of the receiver. If mapBlock returns nil for any value, the returned signal will error using the NSError passed out from the block.

Declared In

RACSignal+Operations.h

waitUntilCompleted:

Blocks the caller and waits for the signal to complete.

- (BOOL)waitUntilCompleted:(NSError **)error

Discussion

Blocks the caller and waits for the signal to complete.

error - If not NULL, set to any error that occurs.

Returns whether the signal completed successfully. If NO, error will be set to the error that occurred.

Declared In

RACSignal+Operations.h

windowWithStart:close:

- (RACSignal *)windowWithStart:(RACSignal *)openSignal close:(RACSignal *( ^ ) ( RACSignal *start ))closeBlock

zipWith:

Zips the values in the receiver with those of the given signal to create RACTuples.

- (RACSignal *)zipWith:(RACSignal *)signal

Discussion

Zips the values in the receiver with those of the given signal to create RACTuples.

The first next of each stream will be combined, then the second next, and so forth, until either signal completes or errors.

signal - The signal to zip with. This must not be nil.

Returns a new signal of RACTuples, representing the combined values of the two signals. Any error from one of the original signals will be forwarded on the returned signal.

Declared In

RACSignal.h