Skip to content

Commit

Permalink
batchPriority is union type
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaskasky committed Jan 4, 2025
1 parent daaf056 commit d7ba0d5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/vanilla/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,20 @@ const addDependency = <Value>(
// Batch
//

type BatchPriority = 0 | 1 | 2

type Batch = Set<() => void>[] & {
/** Atom dependents map */
D: Map<AnyAtom, Set<AnyAtom>>
}

const createBatch = (): Batch => Object.assign([], { D: new Map() })

const addBatchFunc = (batch: Batch, priority: number, fn: () => void) => {
const addBatchFunc = (
batch: Batch,
priority: BatchPriority,
fn: () => void,
) => {
;(batch[priority] ||= new Set()).add(fn)
}

Expand Down

0 comments on commit d7ba0d5

Please sign in to comment.