small tweak

pull/10781/head
Rich Harris 2 years ago
parent 047b557569
commit cc3bcae57d

@ -29,12 +29,12 @@ function get_self() {
return this; return this;
} }
let inited = false;
/** /**
* @template T * @template T
*/ */
export class ReactiveSet extends Set { export class ReactiveSet extends Set {
static #inited = false;
/** @type {Map<T, import('#client').Source<boolean>>} */ /** @type {Map<T, import('#client').Source<boolean>>} */
#sources = new Map(); #sources = new Map();
#version = source(0); #version = source(0);
@ -55,13 +55,13 @@ export class ReactiveSet extends Set {
} }
} }
this.#init(); if (!inited) this.#init();
} }
// We init as part of the first instance so that we can treeshake this class // We init as part of the first instance so that we can treeshake this class
#init() { #init() {
if (!ReactiveSet.#inited) { inited = true;
ReactiveSet.#inited = true;
const proto = ReactiveSet.prototype; const proto = ReactiveSet.prototype;
const set_proto = Set.prototype; const set_proto = Set.prototype;
@ -74,7 +74,6 @@ export class ReactiveSet extends Set {
}; };
} }
} }
}
#increment_version() { #increment_version() {
set(this.#version, this.#version.v + 1); set(this.#version, this.#version.v + 1);

Loading…
Cancel
Save