Tests
All checks were successful
Lint / lint (push) Successful in 14s

This commit is contained in:
Julien Valverdé
2025-06-25 13:38:44 +02:00
parent 1769c4074d
commit 8007c2693a
2 changed files with 21 additions and 19 deletions

View File

@@ -10,6 +10,15 @@
"typescript": "^5.8.3", "typescript": "^5.8.3",
}, },
}, },
"packages/effect-components": {
"name": "effect-components",
"version": "0.1.0",
"peerDependencies": {
"@types/react": "^19.0.0",
"effect": "^3.15.0",
"react": "^19.0.0",
},
},
"packages/example": { "packages/example": {
"name": "@reffuse/example", "name": "@reffuse/example",
"version": "0.0.0", "version": "0.0.0",
@@ -62,7 +71,7 @@
}, },
"packages/extension-query": { "packages/extension-query": {
"name": "@reffuse/extension-query", "name": "@reffuse/extension-query",
"version": "0.1.3", "version": "0.1.5",
"devDependencies": { "devDependencies": {
"reffuse": "workspace:*", "reffuse": "workspace:*",
}, },
@@ -78,7 +87,7 @@
}, },
"packages/reffuse": { "packages/reffuse": {
"name": "reffuse", "name": "reffuse",
"version": "0.1.11", "version": "0.1.13",
"peerDependencies": { "peerDependencies": {
"@types/react": "^19.0.0", "@types/react": "^19.0.0",
"effect": "^3.15.0", "effect": "^3.15.0",
@@ -573,6 +582,8 @@
"effect": ["effect@3.15.1", "", { "dependencies": { "@standard-schema/spec": "^1.0.0", "fast-check": "^3.23.1" } }, "sha512-n3bDF6K3R+FSVuH+dSVU3ya2pI4Wt/tnKzum3DC/3b5e0E9HfhrhbkonOkYU3AVJJOzCA6zZE2/y6EUgQNAY4g=="], "effect": ["effect@3.15.1", "", { "dependencies": { "@standard-schema/spec": "^1.0.0", "fast-check": "^3.23.1" } }, "sha512-n3bDF6K3R+FSVuH+dSVU3ya2pI4Wt/tnKzum3DC/3b5e0E9HfhrhbkonOkYU3AVJJOzCA6zZE2/y6EUgQNAY4g=="],
"effect-components": ["effect-components@workspace:packages/effect-components"],
"electron-to-chromium": ["electron-to-chromium@1.5.152", "", {}, "sha512-xBOfg/EBaIlVsHipHl2VdTPJRSvErNUaqW8ejTq5OlOlIYx1wOllCHsAvAIrr55jD1IYEfdR86miUEt8H5IeJg=="], "electron-to-chromium": ["electron-to-chromium@1.5.152", "", {}, "sha512-xBOfg/EBaIlVsHipHl2VdTPJRSvErNUaqW8ejTq5OlOlIYx1wOllCHsAvAIrr55jD1IYEfdR86miUEt8H5IeJg=="],
"encodeurl": ["encodeurl@2.0.0", "", {}, "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg=="], "encodeurl": ["encodeurl@2.0.0", "", {}, "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg=="],

View File

@@ -1,6 +1,7 @@
import { Box, Text, TextField } from "@radix-ui/themes" import { Box, Text, TextField } from "@radix-ui/themes"
import { createFileRoute } from "@tanstack/react-router" import { createFileRoute } from "@tanstack/react-router"
import { Console, Effect, Layer, ManagedRuntime, Runtime } from "effect" import { Console, Effect, Layer, ManagedRuntime, Runtime } from "effect"
import { ReactComponent } from "effect-components"
import * as React from "react" import * as React from "react"
@@ -11,25 +12,15 @@ export const Route = createFileRoute("/effect-component-tests")({
function RouteComponent() { function RouteComponent() {
const runtime = React.useMemo(() => ManagedRuntime.make(Layer.empty), []) const runtime = React.useMemo(() => ManagedRuntime.make(Layer.empty), [])
return runtime.runSync(Effect.gen(function* RouteComponent() { return <>
const MyTest = yield* useFunctionComponent(MyTestComponent) {runtime.runSync(MyTestComponent.use(Component => (
<Component />
return <> )))}
<MyTest /> </>
</>
}))
} }
const useFunctionComponent = <P, E, R>( const MyTestComponent = ReactComponent.make(Effect.fn(function* MyTestComponent(props?: { readonly value?: string }) {
self: (props: P) => Effect.Effect<React.ReactNode, E, R>
): Effect.Effect<React.FC<P>, never, R> => Effect.gen(function* useFunctionComponent() {
const runtime = yield* Effect.runtime<R>()
return React.useCallback((props: P) => Runtime.runSync(runtime)(self(props)), [runtime])
})
const MyTestComponent = Effect.fn(function*(props?: { readonly value?: string }) {
const [state, setState] = React.useState("value") const [state, setState] = React.useState("value")
const effectValue = yield* Effect.succeed(`state: ${ state }`) const effectValue = yield* Effect.succeed(`state: ${ state }`)
@@ -45,7 +36,7 @@ const MyTestComponent = Effect.fn(function*(props?: { readonly value?: string })
/> />
</Box> </Box>
</> </>
}) }))
const useEffect = <A, E, R>( const useEffect = <A, E, R>(