A tiny RxJS helper library to create reactive derived observables from one or more source streams. Designed to simplify combineLatest, withLatestFrom, and switchMap patterns while keeping everything type-safe, reactive, and readable.
Not been published yet.
Creates a derived observable that reacts to any change in the source observables. Similar to combineLatest, but with a clean compute function.
Supports both spread and array style.
deriveFromBoth(obs1$, obs2$, (a, b) => a + b);deriveFromBoth([obs1$, obs2$], ([a, b]) => a * b);Emits a derived value only when a$ emits, using the latest value(s) from b$.
Supports one or multiple b$ observables.
Useful for avoiding unnecessary emissions from B.
deriveFromAWithB(a$, b$, (a, b) => a + b);deriveFromAWithB(a$, [b1$, b2$], (a, b1, b2) => a + b1 - b2);Use when B is dynamic based on A — i.e., a$ determines which observable(s) to listen to.
Internally uses switchMap.
Supports single or multiple dynamic B observables.
deriveFromDynamicB(a$, a => fetchB$(a), (a, b) => a + b);deriveFromDynamicB(
a$,
a => [fetchB1$(a), fetchB2$(a)],
(a, b1, b2) => a + b1 - b2
);All functions are fully typed. Your compute function will always get autocompletion for the correct values, with no need to cast or destructure manually.
This library uses vitest for unit testing.
npm run testTests cover all functional cases, including edge cases like hot/cold observables, multiple subscriptions, and delayed emissions.
MIT