Currently, version 7+ of RXjS is running where the team has declared many functions as deprecated and it has been decided to remove them completely in either version 8 or version 9.

So we should always show preparation for this so that we can work on the safe side in our current projects and in the future, we too can practice it.

There are many such functions which you are using daily but they are very popular functions and operators but RXjS team has declared them outdated, let us see some functions which you should stop using immediately.


Pluck

pluck selectively picks off a property from each emitted object in the observable sequence and returns an observable of the values of that particular property. pluck was a commonly used function that is being completely removed in RXjS version 8.

What will be the Solution?

You can use map function instead of pluck, here is an example

pluck
map Example

Simply you can use map function inside of pipe function to extract data from the Observable. 


zip

I know you will miss this great function used in RXjS, every developer used once this function.

zip combines multiple observables together, emitting arrays of corresponding elements from each observable. It waits until all observables have emitted an item, then emits the combined array. zip function from rxjs/operators will be removed in RXjS v8.

What will be the Solution?

You can use zipWith function instead.

zip
zipWith example

const zippedObservable = observable1.pipe(zipWith(observable2));
You can se how we have used zipWith function in code example, now you also can try this and the output of given code will be
[A, 1], [B, 2], [C, 3]


concat

concat concatenates multiple observables together, emitting the values from each observable one after the other, in the order they were passed. concat function will me removed in version 8 of RXjS.

What will be the Solution?

Use concatWith function instead to get same functionality like concat.

concat
concatWith example


empty

empty creates an observable sequence that immediately completes without emitting any items. It's useful when you need an observable that does nothing but complete immediately.

empty was a very important function which we will have to lose in RXjS version 8.

What will be the Solution?

use EMPTY constant or scheduled function.

empty
EMPTY example

EMPTY constant will help you to achieve many results and when you create a EMPTY variable it's type will be Observable<never>.



Summary

In today's post we learned about 4 main functions of RXjS library which we have been using daily and which are now deprecated. If you comment, I also promise that I will definitely bring its second part, but till then you also have to promise that you will also try to learn and understand new and advanced things with me. Remember that everyone teaches the basics but only we have to understand the advanced.