pull/14422/head
Simon Holthausen 2 years ago
parent 905556b517
commit 6e2bc3e12c

@ -8,7 +8,7 @@ import { effect_tracking, render_effect } from '../internal/client/reactivity/ef
* "subscriber" count goes from 0 to 1 and back to 0.
* @param {() => () => void} start
*/
export function createStartStopNotifier(start) {
export function createSubscriber(start) {
let subscribers = 0;
/** @type {() => void} */
let stop;

@ -1,7 +1,7 @@
import { get } from '../internal/client/runtime.js';
import { source } from '../internal/client/reactivity/sources.js';
import { effect_tracking } from '../internal/client/reactivity/effects.js';
import { createStartStopNotifier } from './start-stop-notifier.js';
import { createSubscriber } from './create-subscriber.js';
import { on } from '../events/index.js';
import { increment } from './utils.js';
@ -11,7 +11,7 @@ import { increment } from './utils.js';
export class MediaQuery {
#query;
#version = source(0);
#notify = createStartStopNotifier(() => {
#notify = createSubscriber(() => {
return on(this.#query, 'change', () => increment(this.#version));
});

@ -8,7 +8,7 @@ import { source } from '../internal/client/reactivity/sources.js';
import { get as get_source } from '../internal/client/runtime.js';
import { increment } from '../reactivity/utils.js';
import { get, writable } from './shared/index.js';
import { createStartStopNotifier } from '../reactivity/start-stop-notifier.js';
import { createSubscriber } from '../reactivity/create-subscriber.js';
export { derived, get, readable, readonly, writable } from './shared/index.js';
@ -111,7 +111,7 @@ export function fromStore(store) {
let value = /** @type {V} */ (undefined);
let version = source(0);
const notify = createStartStopNotifier(() => {
const notify = createSubscriber(() => {
let ran = false;
const unsubscribe = store.subscribe((v) => {

Loading…
Cancel
Save