This commit is contained in:
@@ -76,13 +76,14 @@ extends Pipeable.Class() implements Form<A, I, R, MA, ME, MR, MP> {
|
|||||||
field<const P extends PropertyPath.Paths<I>>(
|
field<const P extends PropertyPath.Paths<I>>(
|
||||||
path: P
|
path: P
|
||||||
): Effect.Effect<FormField<PropertyPath.ValueFromPath<A, P>, PropertyPath.ValueFromPath<I, P>>> {
|
): Effect.Effect<FormField<PropertyPath.ValueFromPath<A, P>, PropertyPath.ValueFromPath<I, P>>> {
|
||||||
|
const key = new FormFieldKey(path)
|
||||||
return this.fieldCache.pipe(
|
return this.fieldCache.pipe(
|
||||||
Effect.map(HashMap.get(new FormFieldKey(path))),
|
Effect.map(HashMap.get(key)),
|
||||||
Effect.flatMap(Option.match({
|
Effect.flatMap(Option.match({
|
||||||
onSome: v => Effect.succeed(v as FormField<PropertyPath.ValueFromPath<A, P>, PropertyPath.ValueFromPath<I, P>>),
|
onSome: v => Effect.succeed(v as FormField<PropertyPath.ValueFromPath<A, P>, PropertyPath.ValueFromPath<I, P>>),
|
||||||
onNone: () => Effect.tap(
|
onNone: () => Effect.tap(
|
||||||
Effect.succeed(makeFormField(this as Form<A, I, R, MA, ME, MR, MP>, path)),
|
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)
|
return isFormFieldKey(that) && PropertyPath.equivalence(this.path, that.path)
|
||||||
}
|
}
|
||||||
[Hash.symbol]() {
|
[Hash.symbol]() {
|
||||||
return 0
|
return Hash.array(this.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class QueryClientCacheKey implements Equal.Equal {
|
|||||||
return isQueryClientKey(that) && Equivalence.array(Equal.equivalence())(this.key, that.key)
|
return isQueryClientKey(that) && Equivalence.array(Equal.equivalence())(this.key, that.key)
|
||||||
}
|
}
|
||||||
[Hash.symbol]() {
|
[Hash.symbol]() {
|
||||||
return 0
|
return Hash.array(this.key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user