Top Description Inners Fields Constructors Methods
rx.internal.operators

public final Class OperatorScan<R, T>

extends Object
implements Observable.Operator<R, T>
Class Inheritance
All Implemented Interfaces
rx.Observable.Operator, rx.functions.Func1, rx.functions.Function
Type Parameters
<R>
the aggregate and output type
<T>
the input value type
Imports
java.util.Queue, java.util.concurrent.atomic.AtomicLong, rx.*, .Observable.Operator, rx.exceptions.Exceptions, rx.functions.*, rx.internal.util.atomic.SpscLinkedAtomicQueue, rx.internal.util.unsafe.*

Returns an Observable that applies a function to the first item emitted by a source Observable, then feeds the result of that function along with the second item emitted by an Observable into the same function, and so on until all items have been emitted by the source Observable, emitting the result of each of these iterations.

This sort of function is sometimes called an accumulator.

Note that when you pass a seed to scan the resulting Observable will emit that seed as its first emitted item.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv final Func2<R, ? super T, R>
private final Func0<R>
private static final Object

Constructor Summary

AccessConstructor and Description
public
OperatorScan(final R
the initial (seed) accumulator value
initialValue
,
Func2<R, ? super T, R>
an accumulator function to be invoked on each element from the sequence
accumulator
)

Applies an accumulator function over an observable sequence and returns each intermediate result with the specified source and accumulator.

public
OperatorScan(Func0<R> initialValueFactory, Func2<R, ? super T, R> accumulator)

public
OperatorScan(final Func2<R, ? super T, R>
an accumulator function to be invoked on each element from the sequence
accumulator
)

Applies an accumulator function over an observable sequence and returns each intermediate result with the specified source and accumulator.

Method Summary

Modifier and TypeMethod and Description
public Subscriber<? super T>
call(final Subscriber<? super R> child)

Implements rx.functions.Func1.call.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

accumulatorback to summary
pack-priv final Func2<R, ? super T, R> accumulator
initialValueFactoryback to summary
private final Func0<R> initialValueFactory
NO_INITIAL_VALUEback to summary
private static final Object NO_INITIAL_VALUE

Constructor Detail

OperatorScanback to summary
public OperatorScan(final R initialValue, Func2<R, ? super T, R> accumulator)

Applies an accumulator function over an observable sequence and returns each intermediate result with the specified source and accumulator.

Parameters
initialValue:R

the initial (seed) accumulator value

accumulator:Func2<R, ? super T, R>

an accumulator function to be invoked on each element from the sequence

See Also
Observable.Scan(TSource, TAccumulate) Method (IObservable(TSource), TAccumulate, Func(TAccumulate, TSource, TAccumulate))
OperatorScanback to summary
public OperatorScan(Func0<R> initialValueFactory, Func2<R, ? super T, R> accumulator)
OperatorScanback to summary
public OperatorScan(final Func2<R, ? super T, R> accumulator)

Applies an accumulator function over an observable sequence and returns each intermediate result with the specified source and accumulator.

Parameters
accumulator:Func2<R, ? super T, R>

an accumulator function to be invoked on each element from the sequence

Annotations
@SuppressWarnings:unchecked
See Also
Observable.Scan(TSource) Method (IObservable(TSource), Func(TSource, TSource, TSource))

Method Detail

callback to summary
public Subscriber<? super T> call(final Subscriber<? super R> child)

Implements rx.functions.Func1.call.

Annotations
@Override
rx.internal.operators back to summary

pack-priv final Class OperatorScan.InitialProducer<R>

extends Object
implements Producer, Observer<R>
Class Inheritance
All Implemented Interfaces
rx.Observer, rx.Producer

Field Summary

Modifier and TypeField and Description
pack-priv final Subscriber<? super R>
pack-priv volatile boolean
pack-priv boolean
pack-priv Throwable
pack-priv boolean
missed

Missed a terminal event.

pack-priv long
missedRequested

Missed a request.

pack-priv volatile Producer
producer

The current producer.

pack-priv final Queue<Object>
pack-priv final AtomicLong
requested

The current requested amount.

Constructor Summary

AccessConstructor and Description
public
InitialProducer(R initialValue, Subscriber<? super R> child)

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
checkTerminated(boolean d, boolean empty, Subscriber<? super R> child)

pack-priv void
emit()

pack-priv void
public void
onCompleted()

Implements rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.
public void
onError(Throwable
the exception encountered by the Observable
e
)

Implements rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.
public void
onNext(R
the item emitted by the Observable
t
)

Implements rx.Observer.onNext.

Provides the Observer with a new item to observe.
public void
request(long
the maximum number of items you want this Producer to produce, or Long.MAX_VALUE if you want the Producer to produce items at its own pace
n
)

Implements rx.Producer.request.

Request a certain maximum number of items from this Producer.
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

childback to summary
pack-priv final Subscriber<? super R> child
doneback to summary
pack-priv volatile boolean done
emittingback to summary
pack-priv boolean emitting
errorback to summary
pack-priv Throwable error
missedback to summary
pack-priv boolean missed

Missed a terminal event.

missedRequestedback to summary
pack-priv long missedRequested

Missed a request.

producerback to summary
pack-priv volatile Producer producer

The current producer.

queueback to summary
pack-priv final Queue<Object> queue
requestedback to summary
pack-priv final AtomicLong requested

The current requested amount.

Constructor Detail

InitialProducerback to summary
public InitialProducer(R initialValue, Subscriber<? super R> child)

Method Detail

checkTerminatedback to summary
pack-priv boolean checkTerminated(boolean d, boolean empty, Subscriber<? super R> child)
emitback to summary
pack-priv void emit()
emitLoopback to summary
pack-priv void emitLoop()
onCompletedback to summary
public void onCompleted()

Implements rx.Observer.onCompleted.

Doc from rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.

The Observable will not call this method if it calls onError.

Annotations
@Override
onErrorback to summary
public void onError(Throwable e)

Implements rx.Observer.onError.

Doc from rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.

If the Observable calls this method, it will not thereafter call onNext or onCompleted.

Parameters
e:Throwable

the exception encountered by the Observable

Annotations
@Override
onNextback to summary
public void onNext(R t)

Implements rx.Observer.onNext.

Doc from rx.Observer.onNext.

Provides the Observer with a new item to observe.

The Observable may call this method 0 or more times.

The Observable will not call this method again after it calls either onCompleted or onError.

Parameters
t:R

the item emitted by the Observable

Annotations
@Override
requestback to summary
public void request(long n)

Implements rx.Producer.request.

Doc from rx.Producer.request.

Request a certain maximum number of items from this Producer. This is a way of requesting backpressure. To disable backpressure, pass Long.MAX_VALUE to this method.

Requests are additive but if a sequence of requests totals more than Long.MAX_VALUE then Long.MAX_VALUE requests will be actioned and the extras may be ignored. Arriving at Long.MAX_VALUE by addition of requests cannot be assumed to disable backpressure. For example, the code below may result in Long.MAX_VALUE requests being actioned only.

request(100);
request(Long.MAX_VALUE-1);
Parameters
n:long

the maximum number of items you want this Producer to produce, or Long.MAX_VALUE if you want the Producer to produce items at its own pace

Annotations
@Override
setProducerback to summary
public void setProducer(Producer p)