A set of operators to transform actions payload or an atoms state in a FRP style. Simply put, this package is convenient for reactive processing of actions and effects. But some operators could be useful for data processing too, like filter, delay (debounce, throttle) and sample.
Sometimes you already have filteredListAtom from the previous example and it have no internal memoization. So you could use filter operator to prevent extra updates.
Updates filtered by comparator function, which should return true, if new state should continue to propagate. It uses isShallowEqual from utils package by default.
Creates an atom that depending on some condition or data patterns, which can be an atom too. Useful for describing UIs with @reatom/jsx or any other renderers. Here is the example of routing description from the base template↗ (Vite, TypeScript, React, Reatom).
You can call match with any primitive value, computed function, or existing atom. The returned atom depends on the initial expression and contains the undefined state by default. To add handlers and complete the state type, use chain methods. Each chain mutates the original atoms. It is a good practice to use it in the same place where atom was created.
default for replacing undefined fallback state
is for strict comparison
truthy (MDN↗) and falsy (MDN↗) for empty things handling
Sometimes you need to get computed value from an atom in another atom, but you don’t want to trigger the whole computed function, as it could contain other computations. It is the common case for reatomComponent from reatom/npm-react package. The select allows you to perform and memorize some computation by a simple inline callback. It is specially useful when you can’t create separate memorized function because your target atom is dynamically created.
Under the hood select creates additional atom, so you can perform all regular tasks in the callback of the select, just like in the regular computed atom.
Note for a rare cases. A created atom is momorized for the each select by the passed function sources from “toString()” method, so every computed callback in different selects of the same atom should contains differen code. This will throw an error, as the select called multiple times in the same atom with the same string represantation of the passed callback: