Open
Description
Problem
The toUnSignal
function in packages/unuse/src/toUnSignal/index.ts
creates a Vue effect for bidirectional sync without proper cleanup, causing a memory leak when Vue components are unmounted.
Location
Around lines 159-163 in packages/unuse/src/toUnSignal/index.ts
, the effect()
from alien-signals lacks cleanup:
if (!Vue.isReadonly(value)) {
effect(() => {
(value as VueRef<T>).value = result.get();
});
}
Proposed Solution
Capture the dispose function returned by effect()
and call it in an onUnmounted
hook:
if (!Vue.isReadonly(value)) {
const dispose = effect(() => {
(value as VueRef<T>).value = result.get();
});
Vue.onUnmounted(() => dispose());
}
References
- PR: fix: reactivity #10
- Comment: fix: reactivity #10 (comment)
- Requested by: @Shinigami92
Notes
Need to ensure onUnmounted
is available in the current context or use an alternative cleanup mechanism.
Metadata
Metadata
Assignees
Labels
No labels