-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Deprecate the partition operator #3797
Comments
I actually have quite lot of frequent usage around
|
I think I've used it only once. However, I also think I'd be more likely to use it it if were to be a static function. |
Having it as static makes sense to me too. |
I did put together a static version of it in |
I do actually use it quite often, but destructuring two filtered sources actually does the exact same. |
@benlesh I think in codebases where its used quite often, it would be nice to have so you are not constantly repeating yourself. |
Now that I know that partition exists, I could see nice use cases for it. Please do make it static operator. |
@benlesh I understand that #3807 would move us away from the lodash terminology known by many developers. I still believe that it should be called |
That's just the thing... it's not an operator as-is. It returns It's going to have to change one way or another. It's either:
|
Should this discussion maybe wait until the discussion [1] about [1] #3833 |
@benlesh I would go with the second one, as its quite similar to how the original partition worked. I think the first one is nice too, but having two different approaches that effectively solve the same problem can in my opinion be confusing. |
I recently suggested a simpler grouping operator (#3922) and maybe that operator would cover the |
I actually wanted to use |
I was using partition before and it worked great. i recently migrated to rxjs 6 and had a really weird bug when i switched to using two separate filter operators to achieve the result. essentially both filters received true even though the condition function were opposite. so the issue happened because one of the filters receiving and object and resolving to true, it then ran a side effect function and because the value received was an object when the second filter ran the side effect function had mutated the original value and this second filter also resolved to true. this wouldnt have happened with partition. as far as the two options above, i like 1 |
I personally also would go for option 2 |
I agree |
I have a simmilar use case. Handling a stream with diferent outcomes, or different error responses from an http connections is a great use case. I suspect many people have tried to use |
I'm one of those folks who was trying to use partition, then slowly discovering that it is not pipeable. In fact it's also on an httpEvent stream, would be very useful, but just awkward with its current implementation. |
I think that in the new rxjs it's clear that if it is not part of operators
it is not pipeable
…On Fri, Jan 18, 2019, 12:04 PM Aodhan Hayter ***@***.*** wrote:
I actually wanted to use partition in my NGRX Effects, I want to separate
an httpEvent stream that sends event.type 0 to 4 and I want to throttle the
type 3 events and also handle the type 4 (success).
I thought partition was ideal but I don't think I can throttle and merge 2
streams back into one. So when do you use partition?
I have a simmilar use case. Handling a stream with diferent outcomes, or
different error responses from an http connections is a great use case.
I suspect *many people have tried to use partition*, but given that it's
not pipeable they give up on it and end up using filter or something else.
I throw errors and filter them, but dislike throwing errors when the flow
is actually a possible expected event in the stream.
I'm one of those folks who was trying to use partition, then slowly
discovering that it is not pipeable. In fact it's also on an httpEvent
stream, would be very useful, but just awkward with its current
implementation.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3797 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AS0qyhI1CV1sVm_CY2ri1tm-CxLOutKZks5vEf63gaJpZM4Ubm8e>
.
|
@benlesh |
@BioPhoton The partition looks like not exist in some RxJS 6 versions. |
Closing this because |
I think we should deprecate the partition operator and remove it for v7.
Reasons:
partition
isn't really an "operator" in that it returns[Observable<T>, Observable<T>]
rather thanObservable<T>
. This means it doesn't compose via pipe like the others.partition
is easily replaced with the much more widely knownfilter
operator. As partition is effectively the same thing as:const partition = (predicate) => [source.pipe(filter(predicate)), source.pipe(filter((x, i) => !predicate(x, i)))]
The text was updated successfully, but these errors were encountered: