|
|
@ -3,6 +3,7 @@ import { effect_tracking, render_effect } from '../internal/client/reactivity/ef
|
|
|
|
import { source, increment } from '../internal/client/reactivity/sources.js';
|
|
|
|
import { source, increment } from '../internal/client/reactivity/sources.js';
|
|
|
|
import { tag } from '../internal/client/dev/tracing.js';
|
|
|
|
import { tag } from '../internal/client/dev/tracing.js';
|
|
|
|
import { DEV } from 'esm-env';
|
|
|
|
import { DEV } from 'esm-env';
|
|
|
|
|
|
|
|
import { queue_micro_task } from '../internal/client/dom/task.js';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns a `subscribe` function that, if called in an effect (including expressions in the template),
|
|
|
|
* Returns a `subscribe` function that, if called in an effect (including expressions in the template),
|
|
|
@ -68,7 +69,7 @@ export function createSubscriber(start) {
|
|
|
|
subscribers += 1;
|
|
|
|
subscribers += 1;
|
|
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
return () => {
|
|
|
|
queueMicrotask(() => {
|
|
|
|
queue_micro_task(() => {
|
|
|
|
// Only count down after a microtask, else we would reach 0 before our own render effect reruns,
|
|
|
|
// Only count down after a microtask, else we would reach 0 before our own render effect reruns,
|
|
|
|
// but reach 1 again when the tick callback of the prior teardown runs. That would mean we
|
|
|
|
// but reach 1 again when the tick callback of the prior teardown runs. That would mean we
|
|
|
|
// re-subcribe unnecessarily and create a memory leak because the old subscription is never cleaned up.
|
|
|
|
// re-subcribe unnecessarily and create a memory leak because the old subscription is never cleaned up.
|
|
|
|