Decision tree
This page contains most of the available functions provided by @lirx/core
.
They are grouped in a decision tree to help you find the right function suitable for your requirements.
Frequently used functions are in bold.
I want to:
create an Observable from
without notifications
-
nothing and emit no value: empty
-
one/single value
-
a list of values: of
-
an iterable
- array: fromArray
- iterable: fromIterable
- iterator ⚠️: fromIterator
-
something related to the DOM
- an EventTarget: fromEventTarget
- an IntersectionObserver: fromIntersectionObserver
- a ResizeObserver: fromResizeObserver
- a CSS @media query: fromMatchMedia
-
one Observable
- defined later: defer
-
many Observables. When any value is received
- re-emit it concurrently: merge
- combine the values in an array and emit it: combineLatest
- combine the values in an array, runs a function with these values, and emit distinct returned
values:
optimizedReactiveFunction,
reactiveFunction
- arithmetic: reactiveAdd, reactiveAddMany, reactiveSubtract, reactiveMultiply, reactiveDivide
- logic: reactiveAnd, reactiveAndMany, reactiveOr, reactiveOrMany, reactiveNot
- comparison: reactiveEqual, reactiveNotEqual, reactiveGreaterThan, reactiveGreaterThanOrEqual, reactiveLowerThan, reactiveLowerThanOrEqual
- string: reactiveTemplateString
- combine the values in an array, runs a function with these values, and emit distinct returned
values:
optimizedReactiveFunction,
reactiveFunction
-
time related
- emits every 'ms': interval
- emits after 'ms': timeout
- emits when idle time is available: idle
- emits on each animation frame: fromAnimationFrame
with notifications
-
nothing and send a
complete
Notification: emptyWithNotifications -
one/single value
- already defined: singleWithNotifications
-
a list of values: ofWithNotifications
-
an iterable
-
sync
- array: fromArrayWithNotifications
- iterable: fromIterableWithNotifications
- iterator ⚠️: fromIteratorWithNotifications
-
async
- async iterable: fromAsyncIterable
- async iterator ⚠️: fromAsyncIterator
-
-
something related to the DOM
- the user's location (Geolocation): fromGeolocationPosition
-
a promise
- with a factory: fromPromiseFactory
- without a factory ⚠️: fromPromise
-
a readable stream
- w3c streams
- readable stream: fromReadableStream
- readable stream reader ⚠: fromReadableStreamReader
- nodejs:
ReadableandWritabledeprecated. use w3c streams instead.
- w3c streams
-
an http request
-
a blob (reads content): readBlob
-
an error (send an
error
Notification): throwError -
time related
- emits after 'ms':
- with a complete notification: timeoutWithCompleteNotification
- with an error notification: timeoutWithErrorNotification
- emits after 'ms':
-
many Observables:
- equivalent of Promise.all: forkJoin
- equivalent of Promise.race: raceWithNotifications
- equivalent of Promise.any: anyWithNotifications
- equivalent of
merge
: mergeWithNotifications
-
a
rxjs
's Observable: fromRxJS
convert an Observable to
without notifications
- a promise: toPromise
with notifications
-
a promise
- with only the last value: toPromiseLast
- with every value: toPromiseAll
-
an async iterable: toAsyncIterable
-
a ReadableStream: toReadableStream
-
an
RxJS
' Observable: toRxJS
create an ObservablePipe which
without notifications
-
ObserverPipe related
- emits only distinct received values: distinctObservablePipe
- filters received values: filterObservablePipe
- transforms received values: mapObservablePipe
- transforms and filter received values: mapFilterObservablePipe
- transforms distinct received values: mapDistinctObservablePipe
- transforms received values with an accumulator: scanObservablePipe
- reads received values, and re-emits them without transformations: tapObservablePipe
-
Source related
- allows one Observable to emit its values to many Observable:
-
reduces the order of an Observable of Observables
- once: mergeAllSingleObservablePipe
- many: mergeAllObservablePipe
- maps an Observable and then reduces the order:
-
accumulates values:
- until another Observable emits: bufferObservablePipe
- within a fixed period of time: bufferTimeObservablePipe
-
take
- the first value: firstObservablePipe
- the X first values: takeObservablePipe
- the values until another observable emits: takeUntilObservablePipe
- the values until a predicate fails: takeWhileObservablePipe
- the first value that passes a condition: findObservablePipe
-
time related
-
debug an Observable: debugObservablePipe
with notifications
-
awaits to receive a
complete
orerror
Notification, and performs some kind ofmergeMap
: -
converts an Observable of Notification to an Observable:
- accumulates
next
values in an array and send then when acomplete
is received: notificationsToValuesObservablePipe - stores the last
next
value and send it when acomplete
is received: notificationsToLastValueObservablePipe
- accumulates
emit a value myself => create a Source which emits values to
- multiple Observers: createMulticastSource
- only one Observer: createUnicastSource
- one or many Observers and stores all emitted values: createReplaySource, createMulticastReplaySource
- one or many Observers and stores the last emitted value: createReplayLastSource, createMulticastReplayLastSource,
observables and observers from w3c streams
- readable stream: fromReadableStream
- readable stream reader ⚠: fromReadableStreamReader
others
- chain many ObservablePipes: pipeObservablePipes
- chain many ObservablePipes with an Observable: pipeObservable
Can't find a function that suits your needs ? Open a discussion, or create your own and share it !