What it means
rs-x treats Observable-like values as reactive sources. When an Observable emits, dependent expressions re-evaluate and fire changed events.
Core Concepts
Use RxJS Observables directly inside rs-x expressions — emissions flow into the reactive graph and trigger expression updates.
import { BehaviorSubject } from 'rxjs';
import { rsx } from '@rs-x/expression-parser';
const model = {
price: new BehaviorSubject(100),
quantity: 2,
};
// Observable values participate in expressions like normal fields
const totalExpr = rsx<number>('price * quantity')(model);
totalExpr.changed.subscribe(() => {
console.log('total:', totalExpr.value);
});
model.quantity = 3; // logs "total: 300"
model.price.next(120); // logs "total: 360"import { BehaviorSubject } from 'rxjs';
import { rsx } from '@rs-x/expression-parser';
// Observable that emits objects which contain Observables
const model = {
cart: new BehaviorSubject([
{ price: new BehaviorSubject(10) },
{ price: new BehaviorSubject(20) },
]),
};
const firstPrice = rsx<number>('cart[0].price')(model);
firstPrice.changed.subscribe(() => {
console.log('first price:', firstPrice.value);
});
model.cart.value[0].price.next(15); // logs "first price: 15"# CLI (recommended)
rsx init
npm install rxjs
# Manual
npm install @rs-x/core @rs-x/state-manager @rs-x/expression-parser rxjs