chore: tidy up comments and types in batch.js and sources.js (#18980)

couple of trivial tidy-ups, ref #18880
pull/18772/merge
Rich Harris 1 day ago committed by GitHub
parent 0c61f1bb76
commit e22a67c432
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -114,14 +114,14 @@ export class Batch {
/** /**
* The current values of any signals that are updated in this batch. * The current values of any signals that are updated in this batch.
* Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment) * Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
* They keys of this map are identical to `this.#previous` * The keys of this map are identical to `this.previous`
* @type {Map<Value, [any, boolean]>} * @type {Map<Value, [any, boolean]>}
*/ */
current = new Map(); current = new Map();
/** /**
* The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place. * The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
* They keys of this map are identical to `this.#current` * The keys of this map are identical to `this.current`
* @type {Map<Value, any>} * @type {Map<Value, any>}
*/ */
previous = new Map(); previous = new Map();
@ -202,7 +202,6 @@ export class Batch {
#decrement_queued = false; #decrement_queued = false;
constructor() { constructor() {
// link batch
if (last_batch === null) { if (last_batch === null) {
first_batch = last_batch = this; first_batch = last_batch = this;
} else { } else {
@ -1453,7 +1452,7 @@ export function fork(fn) {
}, },
discard: () => { discard: () => {
// cause any MAYBE_DIRTY deriveds to update // cause any MAYBE_DIRTY deriveds to update
// if they depend on things thath changed // if they depend on things that changed
// inside the discarded fork // inside the discarded fork
for (var source of batch.current.keys()) { for (var source of batch.current.keys()) {
source.wv = increment_write_version(); source.wv = increment_write_version();

@ -70,9 +70,9 @@ export function set_eager_effects_deferred() {
*/ */
// TODO rename this to `state` throughout the codebase // TODO rename this to `state` throughout the codebase
export function source(v, stack) { export function source(v, stack) {
/** @type {Value} */ /** @type {Source<V>} */
var signal = { var signal = {
f: 0, // TODO ideally we could skip this altogether, but it causes type errors f: 0,
v, v,
reactions: null, reactions: null,
equals, equals,

Loading…
Cancel
Save