core icon indicating copy to clipboard operation
core copied to clipboard

feat(effectScope): add `onDispose` method

Open Alfred-Skyblue opened this issue 1 year ago • 2 comments

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 */
});

Alfred-Skyblue avatar Apr 28 '24 12:04 Alfred-Skyblue