This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
import { R } from "@/reffuse"
|
|
||||||
import { TodosContext } from "@/todos/reffuse"
|
import { TodosContext } from "@/todos/reffuse"
|
||||||
import { TodosState } from "@/todos/services"
|
import { TodosState } from "@/todos/services"
|
||||||
import { VTodos } from "@/todos/views/VTodos"
|
import { VTodos } from "@/todos/views/VTodos"
|
||||||
import { Container } from "@radix-ui/themes"
|
import { Container } from "@radix-ui/themes"
|
||||||
import { createFileRoute } from "@tanstack/react-router"
|
import { createFileRoute } from "@tanstack/react-router"
|
||||||
import { Console, Effect, Layer } from "effect"
|
import { Layer } from "effect"
|
||||||
import { useMemo } from "react"
|
import { useMemo } from "react"
|
||||||
|
|
||||||
|
|
||||||
@@ -18,10 +17,6 @@ function Index() {
|
|||||||
Layer.provideMerge(TodosState.make("todos"))
|
Layer.provideMerge(TodosState.make("todos"))
|
||||||
), [])
|
), [])
|
||||||
|
|
||||||
R.useEffect(Effect.addFinalizer(() => Console.log("Effect cleanup")).pipe(
|
|
||||||
Effect.flatMap(() => Console.log("Effect recalculated"))
|
|
||||||
))
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { R } from "@/reffuse"
|
import { R } from "@/reffuse"
|
||||||
import { createFileRoute } from "@tanstack/react-router"
|
import { createFileRoute } from "@tanstack/react-router"
|
||||||
import { Console, DateTime, Effect, Ref, Schedule, Stream } from "effect"
|
import { DateTime, Ref, Schedule, Stream } from "effect"
|
||||||
|
|
||||||
|
|
||||||
const timeEverySecond = Stream.repeatEffectWithSchedule(
|
const timeEverySecond = Stream.repeatEffectWithSchedule(
|
||||||
@@ -16,21 +16,7 @@ export const Route = createFileRoute("/time")({
|
|||||||
function Time() {
|
function Time() {
|
||||||
|
|
||||||
const timeRef = R.useRefFromEffect(DateTime.now)
|
const timeRef = R.useRefFromEffect(DateTime.now)
|
||||||
|
R.useFork(Stream.runForEach(timeEverySecond, v => Ref.set(timeRef, v)), [timeRef])
|
||||||
R.useFork(Effect.addFinalizer(() => Console.log("Cleanup")).pipe(
|
|
||||||
Effect.flatMap(() =>
|
|
||||||
Stream.runForEach(timeEverySecond, v => Ref.set(timeRef, v))
|
|
||||||
)
|
|
||||||
), [timeRef])
|
|
||||||
// Reffuse.useFork(Effect.addFinalizer(() => Console.log("Cleanup")).pipe(
|
|
||||||
// Effect.flatMap(() => DateTime.now),
|
|
||||||
// Effect.flatMap(v => Ref.set(timeRef, v)),
|
|
||||||
// Effect.repeat(Schedule.intersect(
|
|
||||||
// Schedule.forever,
|
|
||||||
// Schedule.spaced("1 second"),
|
|
||||||
// )),
|
|
||||||
// ), [timeRef])
|
|
||||||
|
|
||||||
const [time] = R.useRefState(timeRef)
|
const [time] = R.useRefState(timeRef)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user