import { Box, Flex } from "@radix-ui/themes" import { Chunk, Effect, Stream } from "effect" import { Reffuse } from "../reffuse" import { TodosState } from "../services" import { VNewTodo } from "./VNewTodo" import { VTodo } from "./VTodo" export function VTodos() { // Sync changes to the todos with the local storage Reffuse.useFork(TodosState.TodosState.pipe( Effect.flatMap(state => Stream.runForEach(state.todos, () => state.saveToLocalStorage) ) )) const todosRef = Reffuse.useMemo(TodosState.TodosState.pipe(Effect.map(state => state.todos))) const [todos] = Reffuse.useRefState(todosRef) return ( {Chunk.map(todos, (todo, index) => ( ))} ) }