QueryClient work
All checks were successful
Lint / lint (push) Successful in 42s

This commit is contained in:
Julien Valverdé
2025-12-11 04:23:14 +01:00
parent c352b38417
commit 94ba0b0c5e
2 changed files with 5 additions and 4 deletions

View File

@@ -76,13 +76,14 @@ extends Pipeable.Class() implements Form<A, I, R, MA, ME, MR, MP> {
field<const P extends PropertyPath.Paths<I>>(
path: P
): Effect.Effect<FormField<PropertyPath.ValueFromPath<A, P>, PropertyPath.ValueFromPath<I, P>>> {
const key = new FormFieldKey(path)
return this.fieldCache.pipe(
Effect.map(HashMap.get(new FormFieldKey(path))),
Effect.map(HashMap.get(key)),
Effect.flatMap(Option.match({
onSome: v => Effect.succeed(v as FormField<PropertyPath.ValueFromPath<A, P>, PropertyPath.ValueFromPath<I, P>>),
onNone: () => Effect.tap(
Effect.succeed(makeFormField(this as Form<A, I, R, MA, ME, MR, MP>, path)),
v => Ref.update(this.fieldCache, HashMap.set(new FormFieldKey(path), v as FormField<unknown, unknown>)),
v => Ref.update(this.fieldCache, HashMap.set(key, v as FormField<unknown, unknown>)),
),
})),
)
@@ -259,7 +260,7 @@ class FormFieldKey implements Equal.Equal {
return isFormFieldKey(that) && PropertyPath.equivalence(this.path, that.path)
}
[Hash.symbol]() {
return 0
return Hash.array(this.path)
}
}

View File

@@ -36,7 +36,7 @@ class QueryClientCacheKey implements Equal.Equal {
return isQueryClientKey(that) && Equivalence.array(Equal.equivalence())(this.key, that.key)
}
[Hash.symbol]() {
return 0
return Hash.array(this.key)
}
}