0.1.3 #4
@@ -9,7 +9,7 @@ import * as React from "react"
|
||||
|
||||
|
||||
// Generator version
|
||||
const RouteComponent = Component.make(function* AsyncRendering() {
|
||||
const RouteComponent = Component.make(Effect.fnUntraced(function* AsyncRendering() {
|
||||
const MemoizedAsyncComponentFC = yield* MemoizedAsyncComponent
|
||||
const AsyncComponentFC = yield* AsyncComponent
|
||||
const [input, setInput] = React.useState("")
|
||||
@@ -25,7 +25,7 @@ const RouteComponent = Component.make(function* AsyncRendering() {
|
||||
<AsyncComponentFC />
|
||||
</Flex>
|
||||
)
|
||||
}).pipe(
|
||||
})).pipe(
|
||||
Component.withRuntime(runtime.context)
|
||||
)
|
||||
|
||||
@@ -51,7 +51,7 @@ const RouteComponent = Component.make(function* AsyncRendering() {
|
||||
// )
|
||||
|
||||
|
||||
class AsyncComponent extends Component.make(function* AsyncComponent() {
|
||||
class AsyncComponent extends Component.make(Effect.fnUntraced(function* AsyncComponent() {
|
||||
const SubComponentFC = yield* SubComponent
|
||||
|
||||
yield* Effect.sleep("500 millis") // Async operation
|
||||
@@ -63,16 +63,16 @@ class AsyncComponent extends Component.make(function* AsyncComponent() {
|
||||
<SubComponentFC />
|
||||
</Flex>
|
||||
)
|
||||
}).pipe(
|
||||
})).pipe(
|
||||
Suspense.suspense,
|
||||
Suspense.withOptions({ defaultFallback: <p>Loading...</p> }),
|
||||
) {}
|
||||
class MemoizedAsyncComponent extends Memoized.memo(AsyncComponent) {}
|
||||
|
||||
class SubComponent extends Component.make(function* SubComponent() {
|
||||
class SubComponent extends Component.make(Effect.fnUntraced(function* SubComponent() {
|
||||
const [state] = React.useState(yield* Hooks.useOnce(() => Effect.provide(makeUuid4, GetRandomValues.CryptoRandom)))
|
||||
return <Text>{state}</Text>
|
||||
}) {}
|
||||
})) {}
|
||||
|
||||
export const Route = createFileRoute("/dev/async-rendering")({
|
||||
component: RouteComponent
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Component, Memoized } from "effect-fc"
|
||||
import * as React from "react"
|
||||
|
||||
|
||||
const RouteComponent = Component.make(function* RouteComponent() {
|
||||
const RouteComponent = Component.make(Effect.fnUntraced(function* RouteComponent() {
|
||||
const [value, setValue] = React.useState("")
|
||||
|
||||
return (
|
||||
@@ -21,14 +21,14 @@ const RouteComponent = Component.make(function* RouteComponent() {
|
||||
{yield* Effect.map(MemoizedSubComponent, FC => <FC />)}
|
||||
</Flex>
|
||||
)
|
||||
}).pipe(
|
||||
})).pipe(
|
||||
Component.withRuntime(runtime.context)
|
||||
)
|
||||
|
||||
class SubComponent extends Component.make(function* SubComponent() {
|
||||
class SubComponent extends Component.make(Effect.fnUntraced(function* SubComponent() {
|
||||
const id = yield* makeUuid4.pipe(Effect.provide(GetRandomValues.CryptoRandom))
|
||||
return <Text>{id}</Text>
|
||||
}) {}
|
||||
})) {}
|
||||
|
||||
class MemoizedSubComponent extends Memoized.memo(SubComponent) {}
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@ import { Hooks } from "effect-fc/hooks"
|
||||
const TodosStateLive = TodosState.Default("todos")
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
component: Component.make(function* Index() {
|
||||
component: Component.make(Effect.fnUntraced(function* Index() {
|
||||
return yield* Todos.pipe(
|
||||
Effect.map(FC => <FC />),
|
||||
Effect.provide(yield* Hooks.useContext(TodosStateLive, { finalizerExecutionMode: "fork" })),
|
||||
)
|
||||
}).pipe(
|
||||
})).pipe(
|
||||
Component.withRuntime(runtime.context)
|
||||
)
|
||||
})
|
||||
|
||||
@@ -25,7 +25,7 @@ export type TodoProps = (
|
||||
| { readonly _tag: "edit", readonly index: number }
|
||||
)
|
||||
|
||||
export class Todo extends Component.make(function* Todo(props: TodoProps) {
|
||||
export class Todo extends Component.make(Effect.fnUntraced(function* Todo(props: TodoProps) {
|
||||
const runtime = yield* Effect.runtime()
|
||||
const state = yield* TodosState
|
||||
|
||||
@@ -122,6 +122,6 @@ export class Todo extends Component.make(function* Todo(props: TodoProps) {
|
||||
}
|
||||
</Flex>
|
||||
)
|
||||
}).pipe(
|
||||
})).pipe(
|
||||
Memoized.memo
|
||||
) {}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Todo } from "./Todo"
|
||||
import { TodosState } from "./TodosState.service"
|
||||
|
||||
|
||||
export class Todos extends Component.make(function* Todos() {
|
||||
export class Todos extends Component.make(Effect.fnUntraced(function* Todos() {
|
||||
const state = yield* TodosState
|
||||
const [todos] = yield* Hooks.useSubscribeRefs(state.ref)
|
||||
|
||||
@@ -30,4 +30,4 @@ export class Todos extends Component.make(function* Todos() {
|
||||
</Flex>
|
||||
</Container>
|
||||
)
|
||||
}) {}
|
||||
})) {}
|
||||
|
||||
Reference in New Issue
Block a user