Skip to main content

no-zone-critical-rxjs-creation-apis

Legacy guidance

Legacy guidance — since Angular v21, change detection is zoneless by default and Zone.js is dropped from the default bundle. This page documents a legacy approach; Zone.js only may still need it. For new work, prefer the modern approach. See Zoneless & how Zone.js affected change detection for the full picture.

This rule only does anything when Zone.js is present. Since Angular v21, change detection is zoneless by default and Zone.js is dropped from the default bundle, so there is nothing to patch and this rule is a no-op. See Zoneless & how Zone.js affected change detection.

What it flags

RxJS creation functions that emit on Zone-patched timers (for example interval, timer, and time-driven fromEvent pipelines) imported from rxjs. Each emission runs through a patched scheduler and can trigger change detection.

Options

This rule has no options (schema: []).

// eslintrc
{
"rules": {
"@rx-angular/no-zone-critical-rxjs-creation-apis": "error",
},
}
// eslint.config.js (flat config)
import rxAngular from '@rx-angular/eslint-plugin';

export default [
{
plugins: { '@rx-angular': rxAngular },
rules: {
'@rx-angular/no-zone-critical-rxjs-creation-apis': 'error',
},
},
];

Incorrect

// ❌ Incorrect — interval emits on a Zone-patched timer
import { interval } from 'rxjs';

const source = interval(1000);
const subscribe = source.subscribe((val) => console.log(val));

Correct

// ✅ Correct — in a zoneless app (v21+) the scheduler is no longer Zone-patched,
// so the plain rxjs creation function is fine as-is.
import { interval } from 'rxjs';

const source = interval(1000);
const subscribe = source.subscribe((val) => console.log(val));
Do not use rxjs-zone-less

Older guidance suggested importing these creation functions from rxjs-zone-less. That package is unmaintained (RxJS 6/7 only); do not add it or present it as a current path. In a zoneless app you need no wrapper at all; in a residual Zone.js app, unpatch the underlying timer via getZoneUnPatchedApi from @rx-angular/cdk/internals/core instead.

Why

RxJS creation APIs backed by Zone-patched schedulers can trigger unnecessary change-detection runs. Why Zoneless & how Zone.js affected change detection.