0.1.0 #1
@@ -1,5 +1,4 @@
|
|||||||
import { make } from "@thilawyn/reffuse/Reffuse"
|
import { make } from "@thilawyn/reffuse/Reffuse"
|
||||||
import { Layer } from "effect"
|
|
||||||
|
|
||||||
|
|
||||||
export const Reffuse = make(Layer.empty)
|
export const Reffuse = make()
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { Reffuse } from "@/reffuse"
|
import { Reffuse } from "@/reffuse"
|
||||||
import { createRootRoute, Link, Outlet } from "@tanstack/react-router"
|
import { createRootRoute, Link, Outlet } from "@tanstack/react-router"
|
||||||
import { TanStackRouterDevtools } from "@tanstack/router-devtools"
|
import { TanStackRouterDevtools } from "@tanstack/router-devtools"
|
||||||
|
import { Layer } from "effect"
|
||||||
|
import { useMemo } from "react"
|
||||||
|
|
||||||
|
|
||||||
export const Route = createRootRoute({
|
export const Route = createRootRoute({
|
||||||
@@ -8,9 +10,11 @@ export const Route = createRootRoute({
|
|||||||
})
|
})
|
||||||
|
|
||||||
function Root() {
|
function Root() {
|
||||||
|
const layer = useMemo(() => Layer.empty, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Reffuse.Provider>
|
<Reffuse.Provider layer={layer}>
|
||||||
<div className="container mx-auto flex-row justify-center items-center gap-2 mb-4">
|
<div className="container flex-row gap-2 justify-center items-center mx-auto mb-4">
|
||||||
<Link to="/">Index</Link>
|
<Link to="/">Index</Link>
|
||||||
<Link to="/time">Time</Link>
|
<Link to="/time">Time</Link>
|
||||||
<Link to="/count">Count</Link>
|
<Link to="/count">Count</Link>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export const Route = createFileRoute("/count")({
|
|||||||
|
|
||||||
function Count() {
|
function Count() {
|
||||||
|
|
||||||
const runtime = Reffuse.useRuntime()
|
const runSync = Reffuse.useRunSync()
|
||||||
|
|
||||||
const countRef = Reffuse.useRef(0)
|
const countRef = Reffuse.useRef(0)
|
||||||
const [count] = Reffuse.useRefState(countRef)
|
const [count] = Reffuse.useRefState(countRef)
|
||||||
@@ -18,7 +18,7 @@ function Count() {
|
|||||||
return (
|
return (
|
||||||
<div className="container mx-auto">
|
<div className="container mx-auto">
|
||||||
{/* <button onClick={() => setCount((count) => count + 1)}> */}
|
{/* <button onClick={() => setCount((count) => count + 1)}> */}
|
||||||
<button onClick={() => Ref.update(countRef, count => count + 1).pipe(runtime.runSync)}>
|
<button onClick={() => Ref.update(countRef, count => count + 1).pipe(runSync)}>
|
||||||
count is {count}
|
count is {count}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export class Reffuse<R> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const make = <R>(): Reffuse<R> =>
|
export const make = <R = never>(): Reffuse<R> =>
|
||||||
new Reffuse(Runtime.make({
|
new Reffuse(Runtime.make({
|
||||||
context: Context.empty(),
|
context: Context.empty(),
|
||||||
runtimeFlags: RuntimeFlags.make(),
|
runtimeFlags: RuntimeFlags.make(),
|
||||||
|
|||||||
Reference in New Issue
Block a user