core
core copied to clipboard
feat(effectScope): add `onDispose` method
When the effectScope is not active, we can only listen to its dispose in the following way:
const scope = effectScope();
scope.run(() => {});
scope.cleanups.push(() => {
/* code */
});
Although this method solves the current problem, it is rather cumbersome. In this PR, I have added an onDispose method, allowing us to listen to the dispose of effectScope in the following manner:
const scope = effectScope();
scope.run(() => {});
scope.onDispose(() => {
/* code */
});