forked from cartant/eslint-plugin-rxjs
-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
I have a custom RxJS operator which expects an Angular signal as a parameter. Here is a simplified version:
export function indicateLoading<T>(target: WritableSignal<boolean>): ((source: Observable<T>) => Observable<T>) {
return (source: Observable<T>): Observable<T> => {
target.set(true);
return source.pipe(
finalize(() => target.set(false)),
);
};
}
However when I use this operator, the rxjs-x/no-unbound-methods
rule throws an error:
@Injectable()
export class MyAngularService {
private readonly http = inject(HttpClient);
private readonly isLoading = signal(false);
doRequest$(url: string) {
return this.http.get(url).pipe(indicateLoading(this.isLoading));
// ~~~~~~~~~~~~~~
// ESLint: Unbound methods are forbidden. (rxjs-x/no-unbound-methods)
}
}
When binding the signal via this.isLoading.bind(this)
, the .set
function is not available anymore and the operator crashes at runtime. So the only option is to disable the rule.
I suspect the reason behind this is that to read a value from an Angular signal, it needs to be called like a function.
Is there a way for the rule to distinguish between "pure" functions, and other objects like Signals which have extended functionality? If yes, maybe it makes sense to introduce an option to the rule to filter them out.
JasonWeinzierl
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request