feat(core): effects can optionally return a cleanup function#49625
feat(core): effects can optionally return a cleanup function#49625pkozlowski-opensource wants to merge 1 commit intoangular:mainfrom
Conversation
f31ce00 to
4af6b21
Compare
There was a problem hiding this comment.
nit: () => void|WatchCleanupFn seems superfluous, it's a union on identical types.
There was a problem hiding this comment.
Oh wait, I've meant () => (void|WatchCleanupFn) - it is a function that can return another (cleanup) function.
There was a problem hiding this comment.
There was a problem hiding this comment.
This is fine for now, but longer-term we should think about these long-lived operations and error handling. What should happen if an effect or its cleanup function throws an error?
There was a problem hiding this comment.
Agreed. Making a note for myself.
4af6b21 to
7288009
Compare
alxhub
left a comment
There was a problem hiding this comment.
Reviewed-For: public-api
(pending the EffectCleanupFn fix)
|
For anyone wanting to see a real case scenario: https://stackblitz.com/edit/angular-pknifp?file=src%2Fmain.ts (shared on twitter by @lifekefunde) |
dylhunn
left a comment
There was a problem hiding this comment.
reviewed-for: fw-core, public-api
7288009 to
32f9341
Compare
This change extends the effect API surface so effects can, optionally, return a cleanup function. Such function, if returned, is executed prior to the subsequent effect run.
32f9341 to
53fdc46
Compare
|
This PR was merged into the repository by commit 9c5fd50. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This change extends the effect API surface so effects can, optionally, return a cleanup function. Such function, if returned, is executed prior to the subsequent effect run.