Cleanup fix
All checks were successful
Lint / lint (push) Successful in 13s

This commit is contained in:
Julien Valverdé
2025-03-06 03:15:43 +01:00
parent d61339ea6a
commit f99d18b846
3 changed files with 47 additions and 21 deletions

View File

@@ -21,14 +21,20 @@ export const QueryExtension = ReffuseExtension.make(() => ({
this: ReffuseHelpers.ReffuseHelpers<R>,
props: UseQueryProps<A, E, R>,
): UseQueryResult<A, E> {
const runSync = this.useRunSync()
const runner = this.useMemo(() => QueryRunner.make({
query: props.query()
}), [])
this.useEffect(() => Effect.addFinalizer(() => runner.forkInterrupt).pipe(
Effect.andThen(Ref.set(runner.queryRef, props.query())),
Effect.andThen(runner.forkFetch),
), [runner, ...props.key])
React.useEffect(() => {
Ref.set(runner.queryRef, props.query()).pipe(
Effect.andThen(runner.forkFetch),
runSync,
)
return () => { runSync(runner.forkInterrupt) }
}, [runner, ...props.key])
this.useFork(() => runner.refreshOnWindowFocus, [runner])