Skip to content
@pyreon/rx
fundamentals · reactive data

items().sort() just mutated your state. sortBy does not.

Filter, sort, group, search, sum: 43 functions in one package. Pass a signal and get a live computed back; pass a plain array and get an array. Derived lists become one line each, they never mutate the source, and pipe runs a whole chain as one reactive node.

bun add @pyreon/rx
Documentation
functions
43Collections, set operations, aggregation, operators, timing, search and pipe.
in → out
signal → computedA plain array in gives a plain array out.
pipe
1 node for N stagesAn exact count, not a timing.
iOS and Android
shared tierSupported transforms lower to native collection operations; an unsupported one warns by name.
A derived list that never mutates its source Schematic: a products signal in its original order flows through pipe(filter in stock, sortBy price, take 3), which is one reactive node. Adding a plant pot to products recomputes the pipe once and the top three become Plant pot, Desk lamp and Monitor arm. The source list keeps its order; nothing is sorted in place. PIPE · SIGNAL IN, COMPUTED OUT · 42 FUNCTIONS products() Mechanical keyboard$89Desk lamp$24Monitor arm$45Cable trayout of stockPlant pot$12 source order kept pipe(products, …) filter(stock > 0)sortBy(…, 'price')take(…, 3) one reactive node recomputed once top3() 1 Desk lamp2 Monitor arm3 Mechanical keyboard1 Plant pot2 Desk lamp3 Monitor arm a live computed items().sort() mutates the signal’s array · sortBy returns a new one
  • 1 reactive node for a three-stage pipe, where separate calls build threeBENCHMARKS.md §10, rx row: "pipe fuses N nodes into 1 (exact count)" · final pass
  • 43 signal-aware functions in one package, pipe includedpackages/fundamentals/rx/src/index.ts, rx namespace

synthetic · author-run · M3 Max · record of 2026-11-05

Every result, including where we lose →
why teams pick it

Derived data, minus the footguns.

  1. Never mutates the source

    sortBy sorts a copy and compares numbers as numbers, so [1, 10, 2] comes back [1, 2, 10]. A hand-written items().sort() inside a computed reorders the signal's own array.

  2. One function, two modes

    filter(users, fn) with a signal returns a Computed that re-derives when users changes. filter(list, fn) with an array returns an array. Same import on the server, in tests and in components.

  3. pipe is one node

    pipe(products, inStock, byPrice, top3) is one computed: one subscription, one recompute per change. Three separate calls make three nodes and three hops.

  4. Timers that clean up

    debounce(query, 300) gives a signal that settles 300 ms after the last keystroke. Inside a component its effect and pending timer go away on unmount.

the difference

Three computeds, one bug, or one pipe.

by hand

A computed per step. Forget the [...] copy and the sort reorders inStock's cached array in place.

const inStock = computed(() =>
  products().filter((p) => p.stock > 0))
const byPrice = computed(() =>
  [...inStock()].sort((a, b) => a.price - b.price))
const top3 = computed(() => byPrice().slice(0, 3))
with @pyreon/rx

One computed for the chain. Each stage is a plain function; rx helpers on plain arrays return plain arrays.

import { pipe, sortBy, take } from '@pyreon/rx'

const top3 = pipe(
  products,
  (items) => items.filter((p) => p.stock > 0),
  (items) => sortBy(items, 'price'),
  (items) => take(items, 3),
)

top3()  // ['Desk lamp', 'Monitor arm', 'Mechanical keyboard']
products.update((ps) => [...ps, plantPot])
top3()  // ['Plant pot', 'Desk lamp', 'Monitor arm']
coming from

Coming from RxJS?

A filtered, debounced list without a subscription.

RxJS
import { BehaviorSubject, combineLatest, debounceTime, map } from 'rxjs'

const products$ = new BehaviorSubject<Product[]>(initial)
const query$ = new BehaviorSubject('')

const visible$ = combineLatest([
  products$,
  query$.pipe(debounceTime(300)),
]).pipe(
  map(([items, q]) =>
    items.filter((p) => p.name.toLowerCase().includes(q.toLowerCase()))),
  map((items) => [...items].sort((a, b) => a.price - b.price)),
)

const sub = visible$.subscribe(render)
// later: sub.unsubscribe()
Pyreon

@pyreon/rx is not RxJS. RxJS is push-based streams over time: events, HTTP, cancellation with switchMap, schedulers, backpressure. @pyreon/rx is pull-based derivation of the current value of a signal, plus debounce, throttle, scan and distinct for signals. Keep RxJS for event streams; for "a list that depends on other state" this is less code. For requests, use @pyreon/query.

import { For } from '@pyreon/core'
import { signal } from '@pyreon/reactivity'
import { debounce, search, sortBy } from '@pyreon/rx'

const products = signal<Product[]>(initial)
const query = signal('')

function ProductList() {
  // built in the component: the debounce's effect and timer go away on unmount
  const visible = sortBy(search(products, debounce(query, 300), ['name']), 'price')
  // no subscribe, no unsubscribe
  return (
    <ul>
      <For each={visible()} by={(p) => p.id}>{(p) => <li>{p.name}</li>}</For>
    </ul>
  )
}
try it

Search, sort and group a live list.

One pipe over a products signal: search, sort and group. The counter shows how many times the pipe recomputed: once per change, however many stages it has.

sortBy
direction
groupBy
the pipe
pipe(
  products,
  (xs) => search(xs, query(), ['name', 'cat']),
  (xs) => sortBy(xs, key(), dir()),
  (xs) => (grouped() ? groupBy(xs, 'cat') : xs),
)
// query() = '', grouped() = false
// key() = 'name', dir() = 'asc'
  • pipe recomputes1

12 of 12 products

  • Cast iron panKitchen$45
  • Chef knifeKitchen$95
  • Coffee grinderKitchen$89
  • Desk lampHome$39
  • Desk matOffice$29
  • Mechanical keyboardTech$129
  • Monitor armOffice$119
  • Noise headphonesTech$249
  • Plant potHome$19
  • Standing deskOffice$489
  • Throw blanketHome$59
  • USB-C dockTech$179
benchmarks

A pipeline costs one node, not N.

The record's fair peer is the computed you would write without rx; RxJS appears in the harness only as scale context, not as a race. pipe fusing three stages into one node is an exact count. For three rows the harness prints medians with no confidence interval, so the record gives no verdict.

vs a hand-written computed and Solid createMemo · 1,000 rows, bun/JavaScriptCorePyreonrival · lower is better
  • reactive nodes for a three-stage chain
    winexact count, not a timing
  • filter, map, sum
    measuredlevel with or ahead of a hand computed
  • pipe, three stages
    measured1.03×, no CI: no verdict
  • sortBy
    measured1.03×, no CI: no verdict
  • groupBy
    measured1.02×, no CI: no verdict
Apple M3 Max · record of 2026-11-05 · final pass, one run · author-run, syntheticFull method, every loss →
what's included

43 functions, grouped the way you think.

  • Collections filter, map, flatMap, sortBy (asc or desc), groupBy, countBy, keyBy, uniqBy, partition, chunk and more.
  • Slicing take, skip, first, last, takeWhile, dropWhile, sample.
  • Set operations intersection, difference, union, reactive on both inputs.
  • Aggregation count, sum, min, max, average, reduce, every, some. sum, min, max and average take a key or a selector.
  • search(source, query, keys) Case-insensitive match across the fields you name; the query can be a signal.
  • debounce / throttle Signals that settle; torn down with the component, or .dispose() outside one.
  • scan / distinct Running totals, and a signal that only notifies on a real change.
  • combine / zip / merge Join several signals: one function over their values, pairs by index, or one concatenated list.
  • pipe A whole chain in one computed node, typed stage by stage up to seven.
  • rx.* or named imports A namespace for dot-notation, named exports for tree-shaking: the same functions.
recipes

Things to build with it.

A dashboard tile from one source

Totals, counts per category and groups, each a live computed over the same signal.

import { countBy, groupBy, sum } from '@pyreon/rx'

const revenue = sum(orders, 'total')
const perStatus = countBy(orders, 'status')
const byRegion = groupBy(orders, 'region')

const Tile = () => (
  <section>
    <h3>{() => revenue().toFixed(2)}</h3>
    <p>{() => perStatus().paid ?? 0} paid</p>
    <p>{() => Object.keys(byRegion()).length} regions</p>
  </section>
)
Selected rows that survive a refresh

The intersection of what is selected and what is still in the list, live on both sides.

import { signal } from '@pyreon/reactivity'
import { intersection } from '@pyreon/rx'

const visibleIds = signal([1, 2, 3])
const selectedIds = signal([2, 3, 4])
const stillSelected = intersection(visibleIds, selectedIds)

stillSelected()        // [2, 3]
selectedIds.set([3])
stillSelected()        // [3]
api

43 functions and a namespace.

Every export has a reference page with its signature, an example and the mistakes people make with it.

compose · 2
  • pipe
  • rx
collections · 16
  • filter
  • map
  • flatMap
  • sortBy
  • groupBy
  • countBy
  • keyBy
  • uniqBy
  • unique
  • partition
  • chunk
  • flatten
  • compact
  • reverse
  • find
  • mapValues
slicing · 7
  • take
  • skip
  • first
  • last
  • takeWhile
  • dropWhile
  • sample
sets · 3
  • intersection
  • difference
  • union
aggregation · 8
  • count
  • sum
  • min
  • max
  • average
  • reduce
  • every
  • some
operators and timing · 8
  • distinct
  • scan
  • combine
  • zip
  • merge
  • debounce
  • throttle
  • search
types · 2
  • ReadableSignal
  • KeyOf
good to know

Good to know before you start.

Pass the signal, not its value

filter(users, fn) is live. filter(users(), fn) runs once and never updates, because detection is typeof source === 'function'.

Outside a component, dispose timers

debounce, throttle, distinct and scan own an effect. In a component or effectScope it is torn down for you; elsewhere call .dispose().

search reads string fields

search matches only fields whose value is a string, so a number or a nested object in keys never matches. Map it to a string field first, or use filter with your own test.

Not a stream library

No switchMap, no schedulers, no cancellation. For events over time and request racing, RxJS still fits; for server data, @pyreon/query.

questions

What people ask first.

Is this RxJS for signals?

No. It is collection helpers, lodash-style, that understand signals. The benchmark races it against a hand-written computed and Solid's createMemo; RxJS appears there only as scale context, because it solves a different problem.

Is it slower than writing the computed myself?

Filter, map and sum measure level with or ahead of a hand-written computed. pipe of three stages and sortBy read 1.03× behind a hand computed, groupBy 1.02× behind, but the harness prints medians without confidence intervals there, so the record gives them no verdict.

When should I use pipe?

For a chain of two or more steps that nothing else reads in between. It builds one node instead of one per step. If you need an intermediate result elsewhere, keep that step as its own computed.

Does it work on iOS and Android?

The package is in the shared tier: supported transforms, namespaced or imported by name, lower to native collection operations, and an unsupported one warns by name. Native targets are experimental.

Your computed was fine. It just did not need to be written.

bun add @pyreon/rx
Read the rx guide