Avoid separate handlers (prefer-observer)
October 26, 2021 ยท View on GitHub
This rule effects failures if subscribe - or tap - is called with separate handlers instead of an observer.
Rule details
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)
});
Options
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/prefer-observer": [
"error",
{ "allowNext": false }
]
}