-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
cancelled flow() to reject with new FlowCancellationError #2172
Conversation
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.
Hm, given it's just a string, it doesn't seem to be that big deal. It's a weird method of detecting cancel anyway. It might be better to have a custom FlowCancelError
instance that can be checked instead.
@FredyC yes, it's mostly a stylistic issue. I'd be in favor of having a custom error for this, if you guys prefer - it's just a little more invasive but shouldn't be breaking (if we keep the same message) afaict. |
That's exactly my line of thinking :) Perhaps even expose something like Also, we will need this in |
@FredyC ok, so I added
crap, forgot about that. So the same changes (just code, not docs) but for different branch? |
Thanks, I think it's ok. Not exactly the API surface increase, just a cleaner way of handling an existing feature.
I am not sure if Flow is handled differently in MobX4, but chances are it's possible to just cherry pick those commits there and won't need much of the changes. |
I think this is a neat approach indeed. Let's make it part of the next minor |
Still waiting for MobX4 version, @vonovak will you be able to prepare that? |
@FredyC I'll open a new PR for mobx4 in a few hours. |
@FredyC please see #2190 - please note I had to change the implementation from this export class FlowCancellationError extends Error {
constructor() {
super("FLOW_CANCELLED")
}
} to this export function FlowCancellationError() {
this.message = "FLOW_CANCELLED"
}
FlowCancellationError.prototype = Object.create(Error.prototype) as otherwise the tests were failing. Please let me know if you want to use the second impl for this PR too. |
Thanks! |
Published as 5.15.0. Thanks! |
This exports new FlowCancellationError and isFlowCancellationError helper because it's a little unusual to have to rely on
FLOW_CANCELLED
in our code base instead of importing this from mobx.