Skip to content

Instantly share code, notes, and snippets.

@tuannv19
Created March 10, 2020 06:58
Show Gist options
  • Save tuannv19/b4cc832541b7c0ecd70da7bee6a73f44 to your computer and use it in GitHub Desktop.
Save tuannv19/b4cc832541b7c0ecd70da7bee6a73f44 to your computer and use it in GitHub Desktop.
Decision tree
I want to create one Observable
Produces a specific element: just
After a delay: timer
Pull elements from a sequence: from
Generate an element repeatedly: repeatElement
Custom logic exists: create
Generated on every subscription: deferred
Every once in a while, an element is emitted: interval
After a delay: timer
An empty sequence with only one completion event: empty
A sequence that is not generated by any event: never
I want to create a Observableby combining otherObservables
Any one of the Observablegenerated elements, this element is issued: Merge
Let these Observablesone by one element of the issue, when one Observableafter the element has been sent, the next Observablecan begin issuing elements: concat
A combination of a plurality of Observableselements
When each Observablewill issue a new element: ZIP
When any one Observableissue a new element: CombineLatest
I want to convert Observablethe elements, and then they sent to
Convert directly to each element: map
Convert to another Observable: flatMap
Only to receive the latest element of the conversion Observableelement produced: flatMapLatest
Conversion of each element Observablein order to produce elements: concatMap
Based on all traversed elements: scan
I want to delay each element that is generated before sending out: delay
I want to encapsulate the generated events into elements and send them out
Encapsulate them into Event<Element>: materialize
Then unpack it: dematerialize
I want to ignore all nextevents, only receives completedand errorevents: ignoreElements
I want to create a new Observablefront in the original sequence to add some elements: StartWith
I would like Observableafter collecting element, these elements in the cache issue: Buffer
I would like to Observablesplit into multiple Observables: window
Element-based common characteristics: groupBy
I want to receive only Observablethe specific elements
Emits the only element: single
I would like again from Observableissue certain elements
Filter out some elements by determining conditions: filter
Just emit the first few elements: take
Just emit a few elements at the end: takeLast
Emit only the nth element: elementAt
Skip the first few elements
Skip the first n elements: skip
Skip the first few elements that satisfy the decision: skipWhile , skipWhileWithIndex
Skip the first few elements produced over a period of time: skip
Skip the first few elements until another Observableissue element: skipUntil
Take only the first few elements
Take only the first few elements that satisfy the decision: takeWhile , takeWhileWithIndex
Take only the first few elements produced in a certain period of time: take
Just take the first few elements until another Observableissue element: takeUntil
For periodic Observablesampling: the Sample
Emit those elements, no new elements are generated within a certain time after these elements are generated: debounce
No new element is emitted until its value changes: distinctUntilChanged
And provide a function to determine whether the elements are equal: distinctUntilChanged
When you start emitting elements, subscribe after a delay: delaySubscription
I'd like from some of Observablesthe, just take the first generated element Observable: amb
I want to evaluate Observableall the elements
And after application of each element of the polymerization process, all the elements are applied until the polymerization process, the result sent: the reduce
And apply the aggregation method to each element, after each application of the aggregation method, issue the result: scan
I want to Observablebe converted to other data structures: as ...
I want to apply an operator to a Scheduler : subscribeOn
Listen on a Scheduler : observeOn
I want Observablean event occurs, take an action: do
I want to Observablesend a errorevent: error
If no element is generated within the specified time: timeout
I want to Observablewhen an error occurs, an elegant restored
If no element is generated within the specified time, switch to the alternative Observable: timeout
If an error occurs, replace the error with an element: catchErrorJustReturn
If an error occurs, switch to the alternative Observable: catchError
If an error occurs, try again: retry
I've created a Disposableresource, and it Observablehas the same life: a using
I create one Observable, and it doesn't produce the element until I notify it that it can produce the element: publish
And, even if you subscribe after generating an element, you have to emit all elements: replay
And, once all observers cancel the observation, he is released: refCount
Notify that it can produce elements: connect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment