تخطَّ إلى المحتوى

Watcher Without Cleanup (ARCH3322)

هذا المحتوى غير متوفر بلغتك بعد.

Key typescript.vue.watcher-cleanup · Severity warning · Category performance

Vue: flags watch/watchEffect that starts a timer, listener or subscription without a cleanup callback or onScopeDispose, so it outlives the component.

watch(roomId, id => {
socket.subscribe(id, onMessage);
});
watch(roomId, (id, _, onCleanup) => {
socket.subscribe(id, onMessage);
onCleanup(() => socket.unsubscribe(id, onMessage));
});