RxJava2 - nikitachebotarev/docs GitHub Wiki

Observables

  • Observable, Observer(onNext, onError, onComplete, onSubscribe)
  • Flowable, backpressure strategies(drop, buffer, latest), Subscriber(onSubscribe(Subscription), onNext(T), onError(Throwable), onComplete())
  • Single, SingleObserver(onSucess, onError, onSubscribe)
  • Maybe, MaybeObserver(onSuccess, onError, onComplete, onSubscribe)
  • Completable, CompletableObserver(onComplete, onError, onSubscribe)

Subjects

  • Async(возвращает последний элемент source observable, только после того как source observable завершится)
  • Behavior(возвращает последний item и все последующие)
  • Publish(возвращает все последующие items)
  • Replay(возвращает все уже прошедшие items и все последующие)

Backpressure strategies

  • onBackpressureBuffer() (This operator in its parameterless form reintroduces an unbounded buffer between the upstream source and the downstream operator.)
  • onBackpressureBuffer(int capacity) (This is a bounded version that signals BufferOverflowErrorin case its buffer reaches the given capacity.)
  • onBackpressureBuffer(int capacity, Action onOverflow) (This overload calls a (shared) action in case an overflow happens. Its usefulness is rather limited as there is no other information provided about the overflow than the current call stack.)
  • onBackpressureBuffer(int capacity, Action onOverflow, BackpressureOverflowStrategy strategy) (ON_OVERFLOW_ERROR, ON_OVERFLOW_DEFAULT, ON_OVERFLOW_DROP_LATEST, ON_OVERFLOW_DROP_OLDEST)
  • onBackpressureDrop() (Whenever the downstream is not ready to receive values, this operator will drop that elemenet from the sequence.)
  • onBackpressureLatest() (The final operator keeps only the latest value and practically overwrites older, undelivered values.)

Factory methods

  • just
  • fromArray (Signals the elements of the given array and then completes the sequence.)
  • fromIterable (Signals the items from a java.lang.Iterable source (such as Lists, Sets or Collections or custom Iterables) and then completes the sequence.)
  • fromCallable (When a consumer subscribes, the given java.util.concurrent.Callable is invoked and its returned value (or thrown exception) is relayed to that consumer.)
  • fromAction (When a consumer subscribes, the given io.reactivex.function.Action is invoked and the consumer completes or receives the exception the Action threw.)
  • fromRunnable
  • fromFuture (Given a pre-existing, already running or already completed java.util.concurrent.Future, wait for the Future to complete normally or with an exception in a blocking fashion and relay the produced value or exception to the consumers.)
  • from{reactiveType}
  • generate (Creates a cold, synchronous and stateful generator of values.)
  • create (Construct a safe reactive type instance which when subscribed to by a consumer, runs an user-provided function and provides a type-specific Emitter for this function to generate the signal(s) the designated business logic requires. This method allows bridging the non-reactive, usually listener/callback-style world, with the reactive world.)
  • defer (Calls an user-provided java.util.concurrent.Callable when a consumer subscribes to the reactive type so that the Callable can generate the actual reactive instance to relay signals from towards the consumer. defer allows:associating a per-consumer state with such generated reactive instances, allows executing side-effects before an actual/generated reactive instance gets subscribed to, turn hot sources (i.e., Subjects and Processors) into cold sources by basically making those hot sources not exist until a consumer subscribes.)
  • range (Generates a sequence of values to each individual consumer. The range() method generates Integers, the rangeLong() generates Longs.)
  • interval (Periodically generates an infinite, ever increasing numbers (of type Long). The intervalRange variant generates a limited amount of such numbers.)
  • timer (After the specified time, this reactive source signals a single 0L (then completes for Flowable and Observable).)
  • error (Signal an error, either pre-existing or generated via a java.util.concurrent.Callable, to the consumer.)
  • empty (This type of source signals completion immediately upon subscription.)
  • never (This type of source does not signal any onNext, onSuccess, onError or onComplete. )

Schedulers

  • Computation (The default instance has a backing pool of single-threaded ScheduledExecutorService instances equal to the number of available processors (Runtime.availableProcessors()) to the Java VM.)
  • Io (The implementation is backed by a pool of single-threaded ScheduledExecutorService instances that will try to reuse previously started instances used by the worker returned by Scheduler.createWorker() but otherwise will start a new backing ScheduledExecutorService instance.)
  • NewThread (Returns a default, shared Scheduler instance that creates a new Thread for each unit of work.)
  • From(Executor) (creates from java Executor)
  • Single (Returns a default, shared, single-thread-backed Scheduler instance for work requiring strongly-sequential execution on the same background thread.)
  • Trampoline (Returns a default, shared Scheduler instance whose Scheduler.Worker instances queue work and execute them in a FIFO manner on one of the participating threads. The default implementation's Scheduler.scheduleDirect(Runnable) methods execute the tasks on the current thread without any queueing and the timed overloads use blocking sleep as well. Note that this scheduler can't be reliably used to return the execution of tasks to the "main" thread. Such behavior requires a blocking-queueing scheduler currently not provided by RxJava itself but may be found in external libraries.)

Operators

  • Async (fromAction, fromCallable, fromRunnable)
  • Blocking (forEach, first, firstOrDefault, last, lastOrDefault, latest, single)
  • Combining (combineLatest, merge, mergeDelayError, startWith, switchOnNext, zip)
  • Conditional & Boolean (amb, defaultIfEmpty, skipUntil, skipWhile, takeUntil, takeWhile)
  • Connectable (connect, publish, replay, refcount)
  • Creation (factory methods)
  • Error management (doOnError, onErrorComplete, onErrorResumeNext, onErrorReturn, onErrorRetrunItem, onExceptionResumeNext, retry, retryUntil, retryWhen)
  • Filtering (debounce, distinct, distinctUntilChanged, elementAt, elementAtOrError, filter, first, firstElement, firstOrError, ignoreElement, ignoreElements, last, lastElement, lastOrError, ofType, sample, skip, skipLast, take, takeLast, throttleFirst, throttleLast, throttleLatest, throttleWithTimeout, timeout)
  • Mathematical and Aggregate (averageDouble, averageFloat, max, min, sumDouble, sumFloat, sumInt, sumLong, countreduce, reduceWith, collect, collectInto, toList, toSortedList, toMap, toMultimap)
  • Parallel flows (parallel, runOn, sequential)
  • String (byLine, decode, encode, from, join, split, stringConcat)
  • Transformation (buffer, cast, concatMap, concatMapCompletable, concatMapCompletableDelayError, concatMapDelayError, concatMapEager, concatMapEagerDelayError, concatMapIterable, concatMapMaybe, concatMapMaybeDelayError, concatMapSingle, concatMapSingleDelayError, flatMap, flatMapCompletable, flatMapIterable, flatMapMaybe, flatMapObservable, flatMapPublisher, flatMapSingle, flatMapSingleElement, flattenAsFlowable, flattenAsObservable, groupBy, map, scan, switchMap, window)
  • Utility (other)