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

RxJS 5.5: Pipeable Operators #201

Closed
artlowel opened this issue Nov 21, 2017 · 6 comments · Fixed by #320
Closed

RxJS 5.5: Pipeable Operators #201

artlowel opened this issue Nov 21, 2017 · 6 comments · Fixed by #320
Assignees

Comments

@artlowel
Copy link
Member

@artlowel artlowel commented Nov 21, 2017

With the angular 5 update, comes an RxJS update as well. It introduces the concept of lettable operators. The following article explains the concept in detail: https://blog.angularindepth.com/rxjs-understanding-lettable-operators-fe74dda186d3
We should switch to this way of working instead of chaining RxJS operators

@artlowel artlowel added the ready label Jan 25, 2018
@artlowel

This comment has been minimized.

Copy link
Member Author

@artlowel artlowel commented Feb 1, 2018

This article is less detailed and more to the point: https://blog.hackages.io/rxjs-5-5-piping-all-the-things-9d469d1b3f44

@artlowel

This comment has been minimized.

Copy link
Member Author

@artlowel artlowel commented Feb 1, 2018

TL;DR Where you previously wrote:

someObservable
	.map(x => x.y)
	.filter(y => isNotEmpty(y))
	.distinctUntilChanged()
	.subscribe(…)

You can now write

someObservable.pipe(
	map(x => x.y),
	filter(y => isNotEmpty(y)),
	distinctUntilChanged()
).subscribe(…)

Which has the advantage that you only need to include the operators you actually use in the app, so it will be smaller.

It also makes it easier to reuse chunks of code like these that occur in multiple places, because you can simply assign them to a variable and reuse them somewhere else.

const myOperations = pipe(
	map(x => x.y),
	filter(y => isNotEmpty(y)),
	distinctUntilChanged()
)
…
someObservable.let(myOperations).subscribe(…)
@artlowel artlowel changed the title RxJS 5.5: Lettable Operators RxJS 5.5: Pipeable Operators May 9, 2018
@artlowel

This comment has been minimized.

Copy link
Member Author

@artlowel artlowel commented May 9, 2018

"Lettable operators" have been renamed to "Pipeable operators" (source) so I renamed this issue as well.

@ghost ghost assigned Atmire-Kristof May 18, 2018
@ghost ghost added in progress and removed ready labels May 18, 2018
@frederik

This comment has been minimized.

Copy link

@frederik frederik commented May 22, 2018

Hi, just wanted to chip in since I just did a Angular 4->5->6 migration (including a lot of rxjs operators) on one of our projects. I used rxjs-lint as described here https://github.com/reactivex/rxjs-tslint - this worked really well at least for my last migration from 5->6 (e.g. rxjs 6). Before you explore manual options, you might want to give this a try.

@artlowel

This comment has been minimized.

Copy link
Member Author

@artlowel artlowel commented May 22, 2018

Thanks for the tip, I'll give it a try.

@artlowel

This comment has been minimized.

Copy link
Member Author

@artlowel artlowel commented Oct 29, 2018

@courtneypattison I wouldn't start working on this. @LotteHofstede has already used the tool @frederik suggested above to fix all rxjs operators at once in her angular 6 branch. I'll update the task accordingly.

@artlowel artlowel added needs review and removed in progress labels Oct 31, 2018
@tdonohue tdonohue closed this in #320 Dec 3, 2018
@ghost ghost removed the needs review label Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.