Fast, small state management lib for React
import React from "react";
import { dispatch, useSelector } from "tidux";
let $count = 0;
const Increase = () => $count++;
const App = () => {
const count = useSelector(() => $count);
return (
<>
<h1>{count}</h1>
<button onClick={() => dispatch(Increase)}>Increase</button>
</>
);
};
import React from "react";
import { dispatch, useSelector, delay } from "tidux";
let $count = 0;
const Increase = async () => {
await delay(1000);
$count++;
};
const App = () => {
const count = useSelector(() => $count);
return (
<>
<h1>{count}</h1>
<button onClick={() => dispatch(Increase)}>Increase</button>
</>
);
};
import React from "react";
import { dispatch, useSelector, delay } from "tidux";
let $count = 0;
const Increase = () => $count++;
const IncreaseAsync = async () => {
await delay(1000);
Increase();
};
const App = () => {
const count = useSelector(() => $count);
return (
<>
<h1>{count}</h1>
<button onClick={() => dispatch(Increase)}>Increase</button>
<button onClick={() => dispatch(IncreaseAsync)}>Increase Async</button>
</>
);
};
import React from "react";
import { dispatch, useSelector, delay } from "tidux";
let $count = 0;
const Increase = () => $count++;
const IncreaseAsync = async (payload, { dispatch }) => {
await delay(1000);
dispatch(Increase);
};
const App = () => {
const count = useSelector(() => $count);
return (
<>
<h1>{count}</h1>
<button onClick={() => dispatch(Increase)}>Increase</button>
<button onClick={() => dispatch(IncreaseAsync)}>Increase Async</button>
</>
);
};