This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/** biome-ignore-all lint/complexity/useArrowFunction: necessary for class prototypes */
|
/** biome-ignore-all lint/complexity/useArrowFunction: necessary for class prototypes */
|
||||||
import { Effect, Function, Predicate, Runtime, Scope } from "effect"
|
import { Effect, type Equivalence, Function, Predicate, Runtime, Scope } from "effect"
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import * as Component from "./Component.js"
|
import * as Component from "./Component.js"
|
||||||
|
|
||||||
@@ -46,6 +46,30 @@ export const AsyncPrototype: AsyncPrototype = Object.freeze({
|
|||||||
},
|
},
|
||||||
} as const)
|
} as const)
|
||||||
|
|
||||||
|
export const defaultPropsEquivalence: Equivalence.Equivalence<AsyncProps> = (
|
||||||
|
self: Record<string, unknown>,
|
||||||
|
that: Record<string, unknown>,
|
||||||
|
) => {
|
||||||
|
if (self === that)
|
||||||
|
return true
|
||||||
|
|
||||||
|
for (const key in self) {
|
||||||
|
if (key === "fallback")
|
||||||
|
continue
|
||||||
|
if (!(key in that) || !Object.is(self[key], that[key]))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const key in that) {
|
||||||
|
if (key === "fallback")
|
||||||
|
continue
|
||||||
|
if (!(key in self))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const isAsync = (u: unknown): u is Async => Predicate.hasProperty(u, AsyncTypeId)
|
export const isAsync = (u: unknown): u is Async => Predicate.hasProperty(u, AsyncTypeId)
|
||||||
|
|
||||||
@@ -65,7 +89,7 @@ export const async = <T extends Component.Component<any, any, any, any>>(
|
|||||||
>
|
>
|
||||||
& Async
|
& Async
|
||||||
) => Object.setPrototypeOf(
|
) => Object.setPrototypeOf(
|
||||||
Object.assign(function() {}, self),
|
Object.assign(function() {}, self, { propsEquivalence: defaultPropsEquivalence }),
|
||||||
Object.freeze(Object.setPrototypeOf(
|
Object.freeze(Object.setPrototypeOf(
|
||||||
Object.assign({}, AsyncPrototype),
|
Object.assign({}, AsyncPrototype),
|
||||||
Object.getPrototypeOf(self),
|
Object.getPrototypeOf(self),
|
||||||
|
|||||||
Reference in New Issue
Block a user