0.1.0 #1

Merged
Thilawyn merged 87 commits from next into master 2025-01-18 00:54:42 +01:00
Showing only changes of commit 038f38d32c - Show all commits

View File

@@ -1,9 +1,15 @@
import { Reffuse } from "@/reffuse"
import { createFileRoute } from "@tanstack/react-router"
import { Console, DateTime, Effect, Ref, Schedule, SubscriptionRef } from "effect"
import { Console, DateTime, Effect, Ref, Schedule, Stream, SubscriptionRef } from "effect"
import { useMemo } from "react"
const timeEverySecond = Stream.repeatEffectWithSchedule(
DateTime.now,
Schedule.intersect(Schedule.forever, Schedule.spaced("1 second")),
)
export const Route = createFileRoute("/time")({
component: Time
})
@@ -18,18 +24,19 @@ function Time() {
// eslint-disable-next-line react-hooks/exhaustive-deps
), [])
// Reffuse.useFork(Effect.addFinalizer(() => Console.log("Component unmounted.")).pipe(
Reffuse.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.spaced("1 second")),
// ))
Reffuse.useFork(DateTime.now.pipe(
Effect.flatMap(v => Ref.set(timeRef, v)),
Effect.repeat(Schedule.intersect(
Schedule.forever,
Schedule.spaced("1 second"),
)),
))
// Effect.repeat(Schedule.intersect(
// Schedule.forever,
// Schedule.spaced("1 second"),
// )),
// ), [timeRef])
const [time] = Reffuse.useRefState(timeRef)