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
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 install rx4upnpm add rx4uyarn add rx4urx4u vs RxJS
See how rx4u's functional approach compares to traditional object-oriented reactive programming.
RxJS (Object-Oriented)
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)
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!')
);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.