0.1.0 #1

Merged
Thilawyn merged 87 commits from next into master 2025-01-18 00:54:42 +01:00
7 changed files with 40 additions and 23 deletions
Showing only changes of commit 100169952c - Show all commits

BIN
bun.lockb

Binary file not shown.

View File

@@ -14,6 +14,7 @@
"@types/react": "^19.0.4", "@types/react": "^19.0.4",
"@types/react-dom": "^19.0.2", "@types/react-dom": "^19.0.2",
"@vitejs/plugin-react": "^4.3.4", "@vitejs/plugin-react": "^4.3.4",
"effect": "^3.12.1",
"eslint": "^9.17.0", "eslint": "^9.17.0",
"eslint-plugin-react-hooks": "^5.0.0", "eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.16", "eslint-plugin-react-refresh": "^0.4.16",

View File

@@ -1,13 +1,14 @@
import { useState } from 'react' import "./App.css"
import reactLogo from './assets/react.svg' import reactLogo from "./assets/react.svg"
import viteLogo from '/vite.svg' import { Reffuse } from "./Reffuse"
import './App.css' import viteLogo from "/vite.svg"
function App() {
const [count, setCount] = useState(0)
return ( export function App() {
<>
const [count, setCount] = Reffuse.useRefState(Reffuse.useRef(0))
return <>
<div> <div>
<a href="https://vite.dev" target="_blank"> <a href="https://vite.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" /> <img src={viteLogo} className="logo" alt="Vite logo" />
@@ -28,8 +29,6 @@ function App() {
<p className="read-the-docs"> <p className="read-the-docs">
Click on the Vite and React logos to learn more Click on the Vite and React logos to learn more
</p> </p>
</> </>
)
}
export default App }

View File

@@ -0,0 +1,5 @@
import { Reffuse as TReffuse } from "@thilawyn/reffuse"
import { Layer } from "effect"
export const Reffuse = TReffuse.make(Layer.empty)

View File

@@ -1,10 +1,14 @@
import { StrictMode } from 'react' import { StrictMode } from "react"
import { createRoot } from 'react-dom/client' import { createRoot } from "react-dom/client"
import './index.css' import { App } from "./App.tsx"
import App from './App.tsx' import "./index.css"
import { Reffuse } from "./Reffuse.ts"
createRoot(document.getElementById('root')!).render(
<StrictMode> createRoot(document.getElementById("root")!).render(
<App /> <StrictMode>
</StrictMode>, <Reffuse.Provider>
<App />
</Reffuse.Provider>
</StrictMode>
) )

View File

@@ -20,7 +20,11 @@
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true "noUncheckedSideEffectImports": true,
"paths": {
"@/*": ["./src/*"]
}
}, },
"include": ["src"] "include": ["src"]
} }

View File

@@ -1,4 +1,4 @@
import { Effect, Exit, Fiber, ManagedRuntime, Ref, Runtime, Stream, SubscriptionRef } from "effect" import { Effect, Exit, Fiber, Layer, ManagedRuntime, Ref, Runtime, Stream, SubscriptionRef } from "effect"
import React from "react" import React from "react"
@@ -9,7 +9,7 @@ export class Reffuse<R, ER> {
) { ) {
this.Context = React.createContext(runtime) this.Context = React.createContext(runtime)
this.Provider = (props: { readonly children?: React.ReactNode }) => this.Context.Provider({ this.Provider = (props: { readonly children?: React.ReactNode }) => this.Context({
...props, ...props,
value: this.runtime, value: this.runtime,
}) })
@@ -90,3 +90,7 @@ export class Reffuse<R, ER> {
} }
} }
export const make = <ROut, E>(layer: Layer.Layer<ROut, E, never>): Reffuse<ROut, E> =>
new Reffuse(ManagedRuntime.make(layer))