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.
Practical value
Key points
- The pipe is impure (pure: false) — Angular checks it every change-detection cycle, but the pipe itself only recreates the expression when the expression string or context object changes.
- Pass an expression string and a context object: {{ "a + b" | rsx: model }}. Or pass a pre-built IExpression and omit the context: {{ expr | rsx }}.
- When the pipe owns the expression (string input), it disposes the expression on ngOnDestroy. When you pass a pre-built IExpression, the pipe only subscribes — you own the lifecycle.
- providexRsx() registers an APP_INITIALIZER provider that loads the rs-x module, along with providers for IExpressionFactoryToken and IExpressionChangeTransactionManagerToken.
- Inject the change transaction manager with IExpressionChangeTransactionManagerToken when you want to batch multiple model updates into a single change notification — especially when many fields change together.
- Passing null or undefined to the pipe is safe — it renders nothing and cleans up any previous expression.
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 initRelated docs
- Angular official websiteDocs, guides, and Angular ecosystem
- Docs overviewCore concepts and API reference
- First expressionBind expressions and subscribe to changes
- CLIInstall, setup, build, and typecheck workflows
- CompilerBuild-time parsing, validation, and compiled expressions
- Batching transactionsGroup updates and emit once
- PerformanceParsing, binding, update costs, and memory