-
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
feat(share): use another observable to control resets #6169
feat(share): use another observable to control resets #6169
Conversation
963ff5e
to
a94b804
Compare
i have a modified version, which passes the existing test cases (and is more concise), while having the exact same public API. the current approach resulted from a previous attempt, where i used mergeAll insteadof switchAll, to allow "concurrently" running resets. after putting some thought into it, i came to the conclusion that this is not needed (and would involve much more complicated logic beyond just using mergeMap), because the error/complete reset notifiers should always overrule/replace the refCount reset notifiers. |
what can i do, to push this forward? |
Nothing. ATM, I have higher v7 priorities. This would not be a breaking change, so we can implement this after v7 is done/released. It's not a v7 blocker, so it's not near the top of my things-to-do list. |
i actually have the need for this in one of my projects. it is not critical, but would improve behavior. i tried to find a work around by combining other operators (v6), but failed to achieve this behavior, except for having a permanent subscription so it never resets. |
Unfortunately, that doesn't change my priorities. |
In general, I think this is okay, but it's going to need a whole bunch of tests. And it's going to need to be updated to account for the change in #6151 - presumably, once it's no longer a draft, GitHub will show that there's a conflict that needs to be resolved. Maybe start with the latter. |
d682c57
to
4d20d74
Compare
|
4d20d74
to
f32f79e
Compare
This PR is going to need to be rebased again, to account for the change introduced in #6370 Also, I'd prefer this call to rxjs/src/internal/operators/share.ts Lines 207 to 210 in f32f79e
After you've done the rebase, I'll review this and will let you know what needs to be tested. If you're unfamiliar with marble tests, I'll write one to show you what we need to do. This is going to need a lot of tests. |
f32f79e
to
1a93537
Compare
edit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've read through this and I have no further suggestions. It LGTM. I'll prepare a list of what I think we need to test and I'll post it here sometime tomorrow.
i have added some tests already
|
105524f
to
ba0cffc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDK that I'm going to get around to creating that list, today. But one of the things we definitely need to test is that when a reset due to an error or a complete is initiated, any factory passed via the resetOnRefCountZero
is not called.
|
ba0cffc
to
182ee11
Compare
added some cleanups to the impl:
|
I would not add tests for this. It's going to be removed. Regarding the handling of errors from notifiers, IMO we should make no attempt to handle and report them. There is really no avenue for their being reported anyway. Leave them fall through to Lines 22 to 31 in c23e567
It should not reset. The only signal for any of the resets is a next notification. If one isn't received, there should be no reset. Errors should be reported via
Yeah, but we still need to test for it. This is done with other operators, IIRC. It will leak, but that's expected. |
778a9e7
to
ba65f6a
Compare
|
in regards to notifiers emitting errors: we could attach a noop error handler when subscribing to notifiers, if the user wants to handle/react to errors himself he could use |
I think it should be kept as simple as possible. The user is already providing a factory that returns an observable. If a potential error is something they thing they can handle, they already have the opportunity to compose that into the observable they are giving us. |
The list I followed was more of a matrix. You pick all of the ones that make sense from this, for each observable involved:
(clearly, by these standards, none of our operators has 100% coverage, probably, but like I said, pick the ones that make the most sense.) |
i dont fully understand your table. but i guess you mean test coverage based on notifier characteristics? basically, the handling of the notifier observable is tied to
(what do you mean with mixed? a sync emit + something async after?) |
ba65f6a
to
d1447f4
Compare
added some more test cases around sync multi value notifier, as well as firehose observable + sync notifier and explicit test for sync resubscribe with sync notifier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. I'm more than happy with the tests. Thanks, @backbone87. I've suggested adding a comment to your dest
declaration refactor, but approving this now. Thanks.
d1447f4
to
0bea435
Compare
Okay. I finally had time to review this again. This looks really good. The only thing I'm not sure about is that we need to delay reconnect for In the case of complete and error the source is signaling that it's done and can no longer send anything else. What is the purpose of delaying the reseting of the connector at that point? The source can't possibly send anything else. Delaying isn't going to do anything. I can DEFINITELY think of use cases for delaying the reset on ref count. I can think of plenty of use cases there, because that's something downstream. It's not the source saying it can't send anything else. @cartant, since you approved this, maybe you have other thoughts, but it seems like we should only be supporting this for Otherwise, I generally approve of this entire PR. I just think we want to ratchet it back to only the |
After some discussion with @cartant, the feature makes sense. He pointed out that it could be used to cache a completed source for a specified amount of time. That's a reasonable use case for completion. Still unsure about |
Thank you, @backbone87, for this great contribution! |
This is a PoC. I will add tests, if the approach is agreed up on.
Description:
Extends the share operator to allow passing an observable factory to control the reset behavior and enable reset delays.
Related issue (if exists):
closes #4033