Core Concepts

Angular integration

Bind rs-x expressions to Angular templates with the RsxPipe — reactive updates propagate automatically using Angular's change detection, with no manual subscriptions.

What it means

@rs-x/angular includes the RsxPipe impure pipe and the providexRsx() provider function. The pipe wraps an rs-x expression (string or pre-built IExpression) and calls ChangeDetectorRef.markForCheck() whenever the expression value changes. providexRsx() connects the rs-x DI container to Angular's dependency injection system during APP_INITIALIZER.

Practical value

You can mutate the model anywhere in your app, for example from a service, a WebSocket handler, or a button click, and every template that reads that data updates automatically. No BehaviorSubjects, no ngrx actions, and no manually managed subscriptions. The pipe is impure by design, so Angular calls transform() on each change-detection cycle, but it only allocates a new expression when the input actually changes.

Key points

RsxPipe — pre-built IExpression example

Build the expression once in the component class and pass it to the pipe. The pipe subscribes to changes, while the component owns the expression lifecycle.

Preview

Edit the code and the preview recompiles from that updated source.

Live demo

Code

RsxPipe — string expression example

Pass a string expression plus a model object. The pipe creates, owns, and disposes the expression for you.

Preview

Edit the code and the preview recompiles from that updated source.

Live demo

Code

Expression change transactions example

Run the same two async updates with and without a transaction and compare the emitted updates.

Preview

Edit the code and the preview recompiles from that updated source.

Live demo

Code

Setup — standalone app

Register providexRsx() in your application config.

import { ApplicationConfig } from '@angular/core';
import { providexRsx } from '@rs-x/angular';

export const appConfig: ApplicationConfig = {
  providers: [
    // ... other providers
    ...providexRsx(),
  ],
};

Setup — NgModule app

Import RsxPipe and spread providexRsx() into the providers array.

import { NgModule } from '@angular/core';
import { RsxPipe, providexRsx } from '@rs-x/angular';

@NgModule({
  declarations: [AppComponent],
  imports: [RsxPipe],
  providers: [...providexRsx()],
  bootstrap: [AppComponent],
})
export class AppModule {}

RsxPipe — async values

Observable and Promise-backed fields work without a separate async pipe.

Preview

Edit the code and the preview recompiles from that updated source.

Live demo

Code

RsxPipe — null safety

Passing null or undefined is safe and renders as an empty string.

// Passing null or undefined is safe — the pipe renders nothing
// and does not create or hold an expression.

@Component({
  template: `
    <span>{{ maybeExpr | rsx }}</span>
  `,
})
export class SafeComponent {
  maybeExpr: string | null = null; // renders as empty string
}

Installation

Run rsx init in your Angular project to detect the framework, install the right packages, and apply the setup automatically. See the CLI docs.

rsx init