I'm having incredible difficultly trying to remove a property from an observable stream. I have an observable that emits query parameter objects in the url (angular's ActivatedRoute.queryParams
). I'm trying to remove a key & value from the emitted values and calling distinctUntilChanged()
so that their change does not trigger my observer.
The pluck()
allows you to only allow one parameter from a stream through, filter()
allows you to filter entire streams,skip()
operators allow you to skip entire stream emissions, throttle()
to limit the amount of emissions. Though to do the opposite of the pluck()
- where you want to allow all but one value of the stream to pass - doesn't exist. The closest you can get to accomplishing it is a map() that creates a new object, removes the property, and returns that new object, but that's glitchy at best and often times does not work.
I've resorted to creating individual subscriptions for all query parameter properties except for the one I'm attempting to ignore. I imagine there has to be a better way to go about this, is there some magical operator that I'm missing or work around? Why is such an obvious operator missing from the reactive library when something like pluck()
exists?
edit:
Code:
this.activatedRoute.queryParams
.map((value) => {
const newObj = Object.assign({}, value);
delete newObj['page'];
return newObj;
})
.distinctUntilChanged()
.skip(1)
.subscribe(
(value) => console.log(value)
);