0.1.2 (#3)
Co-authored-by: Julien Valverdé <julien.valverde@mailo.com> Reviewed-on: https://gitea:3000/Thilawyn/effect-fc/pulls/3
This commit was merged in pull request #3.
This commit is contained in:
@@ -2,7 +2,7 @@ import * as Domain from "@/domain"
|
||||
import { Box, Button, Flex, IconButton, TextArea } from "@radix-ui/themes"
|
||||
import { GetRandomValues, makeUuid4 } from "@typed/id"
|
||||
import { Chunk, Effect, Match, Option, Ref, Runtime, SubscriptionRef } from "effect"
|
||||
import { Component, Hook } from "effect-fc"
|
||||
import { Component, Hook, Memoized } from "effect-fc"
|
||||
import { SubscriptionSubRef } from "effect-fc/types"
|
||||
import { FaArrowDown, FaArrowUp } from "react-icons/fa"
|
||||
import { FaDeleteLeft } from "react-icons/fa6"
|
||||
@@ -24,7 +24,7 @@ export type TodoProps = (
|
||||
| { readonly _tag: "edit", readonly index: number }
|
||||
)
|
||||
|
||||
export const Todo = Component.make(function* Todo(props: TodoProps) {
|
||||
export class Todo extends Component.make(function* Todo(props: TodoProps) {
|
||||
const runtime = yield* Effect.runtime()
|
||||
const state = yield* TodosState
|
||||
|
||||
@@ -111,5 +111,5 @@ export const Todo = Component.make(function* Todo(props: TodoProps) {
|
||||
</Flex>
|
||||
)
|
||||
}).pipe(
|
||||
Component.memo
|
||||
)
|
||||
Memoized.memo
|
||||
) {}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Todo } from "./Todo"
|
||||
import { TodosState } from "./TodosState.service"
|
||||
|
||||
|
||||
export const Todos = Component.make(function* Todos() {
|
||||
export class Todos extends Component.make(function* Todos() {
|
||||
const state = yield* TodosState
|
||||
const [todos] = yield* Hook.useSubscribeRefs(state.ref)
|
||||
|
||||
@@ -14,19 +14,19 @@ export const Todos = Component.make(function* Todos() {
|
||||
Effect.addFinalizer(() => Console.log("Todos unmounted")),
|
||||
))
|
||||
|
||||
const VTodo = yield* Component.useFC(Todo)
|
||||
const TodoFC = yield* Todo
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<Heading align="center">Todos</Heading>
|
||||
|
||||
<Flex direction="column" align="stretch" gap="2" mt="2">
|
||||
<VTodo _tag="new" />
|
||||
<TodoFC _tag="new" />
|
||||
|
||||
{Chunk.map(todos, (v, k) =>
|
||||
<VTodo key={v.id} _tag="edit" index={k} />
|
||||
<TodoFC key={v.id} _tag="edit" index={k} />
|
||||
)}
|
||||
</Flex>
|
||||
</Container>
|
||||
)
|
||||
})
|
||||
}) {}
|
||||
|
||||
Reference in New Issue
Block a user