QueryClient.make
All checks were successful
Lint / lint (push) Successful in 12s

This commit is contained in:
Julien Valverdé
2025-03-15 22:27:15 +01:00
parent c2bc406a5f
commit c943d81702
5 changed files with 50 additions and 39 deletions

View File

@@ -1,24 +1,17 @@
import { HttpClientError } from "@effect/platform"
import { AlertDialog, Button, Flex, Text } from "@radix-ui/themes"
import { ErrorHandler } from "@reffuse/extension-query"
import { Cause, Chunk, Context, Effect, Match, Option, Stream } from "effect"
import { useState } from "react"
import { AppQueryErrorHandler } from "./query"
import { R } from "./reffuse"
export class QueryErrorHandler extends ErrorHandler.Tag("QueryErrorHandler")<QueryErrorHandler,
HttpClientError.HttpClientError
>() {}
export const QueryErrorHandlerLive = ErrorHandler.layer(QueryErrorHandler)
export function VQueryErrorHandler() {
const [failure, setFailure] = useState(Option.none<Cause.Cause<
ErrorHandler.Error<Context.Tag.Service<QueryErrorHandler>>
ErrorHandler.Error<Context.Tag.Service<AppQueryErrorHandler>>
>>())
R.useFork(() => QueryErrorHandler.pipe(Effect.flatMap(handler =>
R.useFork(() => AppQueryErrorHandler.pipe(Effect.flatMap(handler =>
Stream.runForEach(handler.errors, v => Effect.sync(() =>
setFailure(Option.some(v))
))