-
-
Notifications
You must be signed in to change notification settings - Fork 204
fix(state): handle error emission in connect
using ErrorHandler
#1553
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
base: main
Are you sure you want to change the base?
Conversation
βοΈ Nx Cloud ReportAttention: This version of the Nx Cloud GitHub bot will cease to function on July 1st, 2023. An organization admin can update your integration here. CI is running/has finished running commands for commit fa72532. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. π See all runs for this branch
β Successfully ran 2 targetsSent with π from NxCloud. |
Codecov Report
@@ Coverage Diff @@
## main #1553 +/- ##
==========================================
+ Coverage 81.60% 81.62% +0.01%
==========================================
Files 104 104
Lines 2229 2231 +2
Branches 407 407
==========================================
+ Hits 1819 1821 +2
Misses 332 332
Partials 78 78
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
hello @edbzn thx for the PR :)
I'm not even sure if my comment is actually correct, but I guess we will have a problem with the execution context. If not, please ignore me and I'm going to approve. Sorry, had no time to actually check that, it just came to my mind ^^
private handleError = inject(ErrorHandler).handleError; | ||
private accumulator = createAccumulationObservable<T>({ | ||
handleError: this.handleError, | ||
}); |
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.
We have to make sure the correct execution context is provided. Not sure if the current solution works if you try to access fields inside the handleError
function.
e.g.
class ErrorHandler {
handleError() {
if (this.env === 'prod') {
// do something in prod
}
}
}
could we create an test case for that?
private handleError = inject(ErrorHandler).handleError; | |
private accumulator = createAccumulationObservable<T>({ | |
handleError: this.handleError, | |
}); | |
private errorHandler = inject(ErrorHandler); | |
private accumulator = createAccumulationObservable<T>({ | |
handleError: this.erroHandler.handleError.bind(this.errorHandler), | |
}); |
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 pushed the changes, but the test is failing, I'm not sure to get why. If you have an idea @hoebbelsB.
It's potentially a breaking change as with these changes instantiating RxState outside of Angular injection context will raise the following error:
However, I don't see any good reasons to instantiate RxState outside of a field initializer or a factory function.
Fixes #1536