@residualeffect/rereactor
v3.0.0
Published
React hooks for @residualeffect/reactor
Downloads
5
Readme
rereactor
React hooks for @residualeffect/reactor
Installation
Installation can be accomplished using npm:
npm install @residualeffect/rereactor
Documentation
Implement your application logic using reactor. For example:
import { Observable, Computed } from "@residualeffect/reactor";
export const t = new Observable(3);
export const c = new Computed(() => t.Value * 2);
export function DoSomething() {
t.Value = t.Value + 1;
}
And then utilize your application logic in a react component:
import { useObservable, useComputed } from "@residualeffect/rereactor";
const ExampleComponent: React.FC = () => {
const observedValue = useObservable(t);
const observedComputed = useObservable(c);
const inlineComputed = useComputed(() => t.Value + 1);
return (
<>
<div>Value: {observedValue}</div>
<div>Computed Value: {observedComputed}</div>
<div>Generated Computed: {inlineComputed}</div>
<button onClick={DoSomething}>Go</button>
</>
);
};
License
rereactor is freely distributable under the terms of the MIT License.