0.1.2 (#4)
Some checks failed
Publish / publish (push) Failing after 13s
Lint / lint (push) Successful in 12s

Co-authored-by: Julien Valverdé <julien.valverde@mailo.com>
Reviewed-on: https://gitea:3000/Thilawyn/reffuse/pulls/4
This commit was merged in pull request #4.
This commit is contained in:
Julien Valverdé
2025-02-26 19:27:38 +01:00
parent 8a9f7ad4c2
commit 08f0610752
35 changed files with 1716 additions and 519 deletions

View File

@@ -1,23 +1,24 @@
import { Todo } from "@/domain"
import { Box, Button, Card, Flex, TextArea } from "@radix-ui/themes"
import { Effect, Option } from "effect"
import { Effect, Option, SubscriptionRef } from "effect"
import { R } from "../reffuse"
import { TodosState } from "../services"
const createEmptyTodo = Todo.generateUniqueID.pipe(
Effect.map(id => Todo.Todo.make({
id,
content: "",
completedAt: Option.none(),
}, true))
)
export function VNewTodo() {
const runSync = R.useRunSync()
const createEmptyTodo = Todo.generateUniqueID.pipe(
Effect.map(id => Todo.Todo.make({
id,
content: "",
completedAt: Option.none(),
}, true))
)
const todoRef = R.useRefFromEffect(createEmptyTodo)
const todoRef = R.useMemo(() => createEmptyTodo.pipe(Effect.flatMap(SubscriptionRef.make)), [])
const [todo, setTodo] = R.useRefState(todoRef)
@@ -36,7 +37,7 @@ export function VNewTodo() {
<Button
onClick={() => TodosState.TodosState.pipe(
Effect.flatMap(state => state.prepend(todo)),
Effect.flatMap(() => createEmptyTodo),
Effect.andThen(createEmptyTodo),
Effect.map(setTodo),
runSync,
)}