Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure signatures with thisArg or source observable are deprecated in predicates and projection functions #6143

Closed
benlesh opened this issue Mar 15, 2021 · 2 comments
Assignees
Labels
7.x Issues and PRs for version 7.x

Comments

@benlesh
Copy link
Member

benlesh commented Mar 15, 2021

Just what it says. filter(fn, obj) is more readable as filter(fn.bind(obj)), because the former doesn't really tell us what obj is for. This exists in various parts of the library. We also have signatures where the source observable is provided in the predicate. That is supremely silly, as I can't even think of a use case there, and a simple closure would have worked (for example, every has both an thisArg and a source).

@benlesh benlesh added the AGENDA ITEM Flagged for discussion at core team meetings label Mar 15, 2021
@OliverJAsh
Copy link
Contributor

OliverJAsh commented Mar 17, 2021

+100. I just shipped a bug to production because I accidentally passed an operator as thisArg. Very easy mistake to make:

import { Observable } from 'rxjs';
import { map, shareReplay } from 'rxjs/operators';

declare const ob$: Observable<number>;
// Oops, shareReplay is in the wrong place:
ob$.pipe(map((x) => x + 1, shareReplay()));
// Should have been:
ob$.pipe(map((x) => x + 1), shareReplay());

Even with the improved typings in RxJS v7, it's still possible to make this mistake.

@benlesh
Copy link
Member Author

benlesh commented Mar 24, 2021

Core team approval.

@benlesh benlesh self-assigned this Mar 24, 2021
@benlesh benlesh removed the AGENDA ITEM Flagged for discussion at core team meetings label Mar 24, 2021
@cartant cartant added the 7.x Issues and PRs for version 7.x label May 5, 2021
cartant added a commit to cartant/rxjs that referenced this issue May 5, 2021
cartant added a commit to cartant/rxjs that referenced this issue May 6, 2021
@benlesh benlesh closed this as completed in aa9c3d4 May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
7.x Issues and PRs for version 7.x
Projects
None yet
Development

No branches or pull requests

3 participants