💼 This rule is enabled in the following configs: ✅ recommended
, 🔒 strict
.
🔧💡 This rule is automatically fixable by the --fix
CLI option and manually fixable by editor suggestions.
💭 This rule requires type information.
This rule effects failures if subscribe
- or tap
- is called with separate handlers instead of an observer.
Examples of incorrect code for this rule:
import { of } from "rxjs";
of(42, 54).subscribe((value) => console.log(value));
Examples of correct code for this rule:
import { of } from "rxjs";
of(42, 54).subscribe({
next: (value) => console.log(value)
});
Name | Description | Type | Default |
---|---|---|---|
allowNext |
Allows a single next callback. |
Boolean | true |
This rule accepts a single option which is an object with an allowNext
property that determines whether a single next
callback is allowed. By default, allowNext
is true
.
{
"rxjs-x/prefer-observer": [
"error",
{ "allowNext": false }
]
}
If you rely on RxJS's deprecation of separate handlers and don't need to double-flag usage, then you don't need this rule.
Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.