Skip to content

Commit

Permalink
fix(lens): match ctx instead of cause in select
Browse files Browse the repository at this point in the history
  • Loading branch information
artalar committed Jun 22, 2024
1 parent e0b9cf8 commit 3f1fd8e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/lens/src/select.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
Atom,
AtomCache,
AtomProto,
Ctx,
CtxSpy,
__count,
atom,
Expand All @@ -16,16 +16,16 @@ const mapAtom = atom(
)
mapAtom.__reatom.initState = () => new WeakMap()

const touchedMap = new WeakMap<AtomCache, Set<FunctionSource>>()
const touchedMap = new WeakMap<Ctx, Set<FunctionSource>>()

export const select = <T>(
ctx: CtxSpy,
cb: (ctx: CtxSpy) => T,
equal: (oldState: T, newState: T) => boolean = () => false,
): T => {
let touched = touchedMap.get(ctx.cause)
let touched = touchedMap.get(ctx)
if (!touched) {
touchedMap.set(ctx.cause, (touched = new Set()))
touchedMap.set(ctx, (touched = new Set()))
}

const map = ctx.get(mapAtom)
Expand Down

0 comments on commit 3f1fd8e

Please sign in to comment.