Inherits from RACArraySequence : RACSequence : RACStream : NSObject
Declared in RACEagerSequence.h
RACEagerSequence.m

Overview

Private class that implements an eager sequence.

Class Methods

return:

Lifts value into the stream monad.

+ (instancetype)return:(id)value

Discussion

Returns a stream containing only the given value.

Declared In

RACStream.h

Instance Methods

bind:

Lazily binds a block to the values in the receiver.

- (instancetype)bind:(RACStreamBindBlock ( ^ ) ( void ))block

Discussion

This should only be used if you need to terminate the bind early, or close over some state. flattenMap: is more appropriate for all other cases.

block - A block returning a RACStreamBindBlock. This block will be invoked each time the bound stream is re-evaluated. This block must not be nil or return nil.

Returns a new stream which represents the combined result of all lazy applications of block.

Declared In

RACStream.h

concat:

Appends the values of stream to the values in the receiver.

- (instancetype)concat:(RACSequence *)sequence

Discussion

stream - A stream to concatenate. This must be an instance of the same concrete class as the receiver, and should not be nil.

Returns a new stream representing the receiver followed by stream.

Declared In

RACStream.h

eagerSequence

Converts a sequence into an eager sequence.

- (RACSequence *)eagerSequence

Discussion

An eager sequence fully evaluates all of its values immediately. Sequences derived from an eager sequence will also be eager.

Returns a new eager sequence, or the receiver if the sequence is already eager.

Declared In

RACSequence.h

foldRightWithStart:reduce:

Applies a right fold to the sequence.

- (id)foldRightWithStart:(id)start reduce:(id ( ^ ) ( id , RACSequence *rest ))reduce

Discussion

A right fold is equivalent to recursion on the list. The block is evaluated from the right to the left in list. It is right associative so it’s applied to the rightmost elements first. For example, in the sequence [1,2,3] the block is applied in the order: reduce(1, reduce(2, reduce(3, start)))

start - The starting value for the fold. reduce - The block used to combine the accumulated value and the next head. The block is given the accumulated value and the value of the rest of the computation (result of the recursion). This is computed when you retrieve its value using rest.head. This allows you to prevent unnecessary computation by not accessing rest.head if you don’t need to.

Returns a reduced value.

Declared In

RACSequence.h

lazySequence

Converts a sequence into a lazy sequence.

- (RACSequence *)lazySequence

Discussion

A lazy sequence evaluates its values on demand, as they are accessed. Sequences derived from a lazy sequence will also be lazy.

Returns a new lazy sequence, or the receiver if the sequence is already lazy.

Declared In

RACSequence.h