Creating
Module Rx.From collects functions for creating reactive sources.
Basic values
From.boolean , From.number , From.string are writable reactives for basic types.
Arrays
From.array reads individual values from an array with a given interval between values. It is non-writable, and works with a snapshot of the array, so it doesn’t pick up on changes to the array after it is created.
It is a finite reactive (since arrays themselves are finite). Read the isDone
property to check if it has completed.
From.arrayObject wraps a source array and emits the whole array. It provides a set of functions for manipulating the array such that changes will be properly emitted to subscribers.
Events
From.event emits data from events, typically for user interaction events.
It’s created from an event target and event name. The event target can be an HTML element or query, such as “#someEl”.
An initial value should be provided. This improves the typing of the return reactive and allows you to immediately use the .last
property, before the event fires.
From.eventField works similarly, but allows you to specify a single field name to pluck from the event object.
Functions
From.func emits values by calling a function at a given interval.
The reactive can be limited with the maximumRepeats
option (to set total number of values emitted), using an abort signal, or calling the provided abort function.
If you don’t specify an interval (or manual: true
is specified), it will be in manual mode. It won’t call the provided function (and thus emit a value) unless the source is pinged.
Iterables
Reactives can be made from async or synchronous iterators/generators with From.iterator .