rx4u

Functional Reactive Programming Library for JavaScript and TypeScript

A lightweight, pure functional alternative to RxJS with better performance and simpler composition patterns.

Simple. Functional. Powerful.

Experience reactive programming with pure functions and elegant composition.

Create and transform streams effortlessly

  • Pure functional approach
  • Lazy execution model
  • TypeScript-first design
  • Lightweight and performant
JavaScript
import { of, pipeFrom, map, filter, take } from 'rx4u';

// Create a stream from values
const numbers$ = of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

// Compose operators with pipeFrom
const result$ = pipeFrom(
  numbers$,
  filter(x => x % 2 === 0),  // Keep even numbers
  map(x => x * 2),           // Double each
  take(3)                    // Take first 3
);

// Subscribe to the stream
result$(
  value => console.log(value),    // 4, 8, 12
  error => console.error(error),
  () => console.log('Complete!')
);

Get Started in Seconds

Install rx4u with your favorite package manager and start building reactive applications.

npm
npm install rx4u
pnpm
pnpm add rx4u
yarn
yarn add rx4u

rx4u vs RxJS

See how rx4u's functional approach compares to traditional object-oriented reactive programming.

RxJS (Object-Oriented)

JavaScript
import { of, map, filter, take } from 'rxjs';

const numbers$ = of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

const result$ = numbers$.pipe(
  filter(x => x % 2 === 0),
  map(x => x * 2),
  take(3)
);

result$.subscribe(
  value => console.log(value),
  error => console.error(error),
  () => console.log('Complete!')
);

rx4u (Functional)

JavaScript
import { of, pipeFrom, map, filter, take } from 'rx4u';

const numbers$ = of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

const result$ = pipeFrom(
  numbers$,
  filter(x => x % 2 === 0),
  map(x => x * 2),
  take(3)
);

result$(
  value => console.log(value),
  error => console.error(error),
  () => console.log('Complete!')
);
Pure Functions
No classes, no inheritance
TypeScript First
Complete type inference
Lightweight and performant
Minimal bundle footprint

Why Choose rx4u?

High Performance

Optimized for speed with minimal overhead and efficient memory usage.

Type Safe

Built with TypeScript for excellent IDE support and compile-time safety.

Functional Design

Pure functions and composable operators for predictable behavior.

Reactive State

Built-in createState and createLazyState for reactive state management.

Memory Safe

Automatic cleanup on unsubscription with no hidden references.

Tree Shaking

Import only what you need. Unused operators are eliminated at build time.