RACDynamicSequence Class Reference
Inherits from | RACSequence : RACStream : NSObject |
Declared in | RACDynamicSequence.h RACDynamicSequence.m |
Class Methods
sequenceWithHeadBlock:tailBlock:
Creates a sequence that dynamically generates its values.
+ (RACSequence *)sequenceWithHeadBlock:(id ( ^ ) ( void ))headBlock tailBlock:(RACSequence *( ^ ) ( void ))tailBlock
Discussion
headBlock - Invoked the first time head is accessed. tailBlock - Invoked the first time tail is accessed.
The results from each block are memoized, so each block will be invoked at most once, no matter how many times the head and tail properties of the sequence are accessed.
Any side effects in headBlock
or tailBlock
should be thread-safe, since
the sequence may be evaluated at any time from any thread. Not only that, but
tail may be accessed before head, or both may be accessed simultaneously.
As noted above, side effects will only be triggered the first time head or
tail is invoked.
Returns a sequence that lazily invokes the given blocks to provide head and
tail. headBlock
must not be nil.
Declared In
RACSequence.h
sequenceWithLazyDependency:headBlock:tailBlock:
Returns a sequence which evaluates dependencyBlock
only once, the first
time either headBlock
or tailBlock
is evaluated. The result of
dependencyBlock
will be passed into headBlock
and tailBlock
when
invoked.
+ (RACSequence *)sequenceWithLazyDependency:(id ( ^ ) ( void ))dependencyBlock headBlock:(id ( ^ ) ( id dependency ))headBlock tailBlock:(RACSequence *( ^ ) ( id dependency ))tailBlock
Declared In
RACDynamicSequence.h
Instance Methods
head
The first object in the sequence, or nil if the sequence is empty.
- (id)head
Discussion
Subclasses must provide an implementation of this method.
Declared In
RACSequence.h
tail
All but the first object in the sequence, or nil if the sequence is empty.
- (RACSequence *)tail
Discussion
Subclasses must provide an implementation of this method.
Declared In
RACSequence.h