import { R } from "@/reffuse"
import { createFileRoute } from "@tanstack/react-router"
import { Console, Effect } from "effect"


export const Route = createFileRoute("/tests")({
    component: RouteComponent
})

function RouteComponent() {
    // R.useMemo(Effect.addFinalizer(() => Console.log("Cleanup!")).pipe(
    //     Effect.map(() => "test")
    // ))

    R.useSuspenseScoped(Effect.addFinalizer(() => Console.log("cleanup")).pipe(
        Effect.andThen(Effect.promise(() => new Promise<string>(resolve => {
            setTimeout(() => { resolve("test") }, 0)
        }))),

        Effect.tap(Console.log),
    ), [])

    return <div>Hello "/tests"!</div>
}
