Skip to content

Commit

Permalink
feat(reactivity): add failSilently argument for onScopeDispose
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Mar 7, 2024
1 parent ef2eaef commit 9a936aa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/reactivity/src/effectScope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ export function getCurrentScope() {
* @param fn - The callback function to attach to the scope's cleanup.
* @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
*/
export function onScopeDispose(fn: () => void) {
export function onScopeDispose(fn: () => void, failSilently = false) {
if (activeEffectScope) {
activeEffectScope.cleanups.push(fn)
} else if (__DEV__) {
} else if (__DEV__ && !failSilently) {
warn(
`onScopeDispose() is called when there is no active effect scope` +
` to be associated with.`,
Expand Down

0 comments on commit 9a936aa

Please sign in to comment.