useScope refactoring
All checks were successful
Lint / lint (push) Successful in 13s
Test build / test-build (pull_request) Successful in 16s

This commit is contained in:
Julien Valverdé
2025-05-19 13:58:12 +02:00
parent 45ab641262
commit ffba43c259
2 changed files with 13 additions and 14 deletions

View File

@@ -2,7 +2,7 @@ import { R } from "@/reffuse"
import { Button, Flex, Text } from "@radix-ui/themes"
import { createFileRoute } from "@tanstack/react-router"
import { GetRandomValues, makeUuid4 } from "@typed/id"
import { Console, Effect, Option, Scope } from "effect"
import { Console, Effect, Option } from "effect"
import { useEffect, useState } from "react"
@@ -24,13 +24,13 @@ function RouteComponent() {
const uuidStream = R.useStreamFromReactiveValues([uuid])
const uuidStreamLatestValue = R.useSubscribeStream(uuidStream)
const scope = R.useScope([uuid])
const [, scopeLayer] = R.useScope([uuid])
useEffect(() => Effect.addFinalizer(() => Console.log("Scope cleanup!")).pipe(
Effect.andThen(Console.log("Scope changed")),
Effect.provideService(Scope.Scope, scope),
Effect.provide(scopeLayer),
runSync,
), [scope, runSync])
), [scopeLayer, runSync])
return (
<Flex direction="column" justify="center" align="center" gap="2">