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 computer, but you don’t want to trigger other recomputations if the computed value is not changed. 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.
Important note is that you could use only one select in each atom, this is done for performance reasons and API simplicity. If, for some reason, you really need a few select, you could nest it and call one in another and so on.