RxJava basics

Marble diagrams

map example

Observable creation

Main function

Observable.create(Observable.onSubscribe)

Other

from( ) — convert an Iterable or a Future or single value into an Observable
repeat( ) — create an Observable that emits a particular item or sequence of items repeatedly
timer( ) — create an Observable that emits a single item after a given delay
empty( ) — create an Observable that emits nothing and then completes
error( ) — create an Observable that emits nothing and then signals an error
never( ) — create an Observable that emits nothing at all

Observable transformation

map( ) — transform the items emitted by an Observable by applying a function to each of them

flatMap( ) — transform the items emitted by an Observable into Observables, then flatten this into a single Observable

scan( ) — apply a function to each item emitted by an Observable, sequentially, and emit each successive value

groupBy( ) and groupByUntil( ) — divide an Observable into a set of Observables that emit groups of items from the original Observable, organized by key

buffer( ) — periodically gather items from an Observable into bundles and emit these bundles rather than emitting the items one at a time

window( ) — periodically subdivide items from an Observable into Observable windows and emit these windows rather than emitting the items one at a time

Map

flatMap

map, then flatten

scan

groupBy

buffer

Observable filtering

filter( ) — filter items emitted by an Observable

takeLast( ) — only emit the last n items emitted by an Observable

takeLastBuffer( ) — emit the last n items emitted by an Observable, as a single list item

skip( ) — ignore the first n items emitted by an Observable

take( ) — emit only the first n items emitted by an Observable

first( ) — emit only the first item emitted by an Observable, or the first item that meets some condition

elementAt( ) — emit item n emitted by the source Observable

timeout( ) — emit items from a source Observable, but issue an exception if no item is emitted in a specified timespan