Working mutations
All checks were successful
Lint / lint (push) Successful in 14s

This commit is contained in:
Julien Valverdé
2025-03-17 02:15:27 +01:00
parent d56578da8f
commit 8636a28f2f
4 changed files with 34 additions and 9 deletions

View File

@@ -1,12 +1,14 @@
import * as AsyncData from "@typed/async-data"
import { type Context, Effect, Ref, SubscriptionRef } from "effect"
import { type Context, Effect, type Fiber, Ref, SubscriptionRef } from "effect"
import type * as QueryClient from "./QueryClient.js"
export interface MutationRunner<K extends readonly unknown[], A, E, R> {
readonly context: Context.Context<R>
readonly stateRef: SubscriptionRef.SubscriptionRef<AsyncData.AsyncData<A, E>>
readonly mutate: (...key: K) => Effect.Effect<A, E>
readonly forkMutate: (...key: K) => Effect.Effect<Fiber.RuntimeFiber<A, E>>
}
@@ -40,9 +42,13 @@ export const make = <EH, K extends readonly unknown[], A, E, HandledE, R>(
Effect.provide(context),
)
const forkMutate = (...key: K) => Effect.forkDaemon(mutate(...key))
return {
context,
stateRef,
mutate,
forkMutate,
}
})