@@ -2,7 +2,7 @@ import * as Domain from "@/domain"
|
||||
import { Button, Flex, TextArea } from "@radix-ui/themes"
|
||||
import { GetRandomValues, makeUuid4 } from "@typed/id"
|
||||
import { Chunk, Effect, Match, Option, Ref, Runtime, SubscriptionRef } from "effect"
|
||||
import { ReactComponent, ReactHook } from "effect-fc"
|
||||
import { Component, Hook } from "effect-fc"
|
||||
import { SubscriptionSubRef } from "effect-fc/types"
|
||||
import * as React from "react"
|
||||
import { TodosState } from "./TodosState.service"
|
||||
@@ -19,18 +19,18 @@ export type TodoProps = (
|
||||
}
|
||||
)
|
||||
|
||||
export const Todo = ReactComponent.make(function* Todo(props: TodoProps) {
|
||||
export const Todo = Component.make(function* Todo(props: TodoProps) {
|
||||
const runtime = yield* Effect.runtime()
|
||||
const state = yield* TodosState
|
||||
|
||||
const ref = yield* ReactHook.useMemo(() => Match.value(props).pipe(
|
||||
const ref = yield* Hook.useMemo(() => Match.value(props).pipe(
|
||||
Match.tag("new", () => Effect.andThen(makeTodo, SubscriptionRef.make)),
|
||||
Match.tag("edit", ({ ref }) => Effect.succeed(ref)),
|
||||
Match.exhaustive,
|
||||
), [props._tag, props.ref])
|
||||
|
||||
const contentRef = React.useMemo(() => SubscriptionSubRef.makeFromPath(ref, ["content"]), [ref])
|
||||
const [todo] = yield* ReactHook.useSubscribeRefs(ref)
|
||||
const [todo] = yield* Hook.useSubscribeRefs(ref)
|
||||
|
||||
return (
|
||||
<Flex direction="column" align="stretch" gap="2">
|
||||
|
||||
Reference in New Issue
Block a user