0.1.0 #1
@@ -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",
|
||||||
|
|||||||
@@ -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
|
}
|
||||||
|
|||||||
5
packages/example/src/Reffuse.ts
Normal file
5
packages/example/src/Reffuse.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import { Reffuse as TReffuse } from "@thilawyn/reffuse"
|
||||||
|
import { Layer } from "effect"
|
||||||
|
|
||||||
|
|
||||||
|
export const Reffuse = TReffuse.make(Layer.empty)
|
||||||
@@ -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>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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))
|
||||||
|
|||||||
Reference in New Issue
Block a user