0.11.1-alpha.0 • Published 2 years ago
actus v0.11.1-alpha.0
actus
Minimalist, boilerplate-free, framework-agnostic state container
- Simple - it takes 2 minutes to learn
- Boilerplate-free
- comes with built-in default actions (
set()
,reset()
,toggle()
,merge()
, etc.) - handles loading and error states for async actions for you
- comes with built-in default actions (
- Framework-agnostic
Examples
React Counter App
import { actus } from "actus";
import React from "react";
import ReactDOM from "react-dom";
actus({
state: 0,
subscribers: [
({ state, actions }) => {
ReactDOM.render(
<>
<h1>{state}</h1>
<button onClick={actions.increment}>+</button>
<button onClick={actions.decrement}>-</button>
</>,
document.querySelector("#root")
);
},
],
});
API
import { actus } from "actus";
// actus() returns actions bound to the current state, in case if you need them
// outside of subscribers:
const actions = actus({
// The initial state:
state: { number: 0 },
// Actions accept an optional payload and the current state, and must return
// a new state:
actions: {
number: {
add: ({ state, payload }) => state + payload,
},
},
// Subscribers will be called sequentially during initialization and then
// after any action call:
subscribers: [({ state, actions, actionName, payload }) => {}],
});
// The first argument is the payload:
actions.number.add(1);
Plugins
The following plugins are enabled automatically (but can be redefined manually if needed):
- defaultActions - basic actions for your state properties (
set()
,reset()
,toggle()
,merge()
, etc.) - logger - logs actions and state changes to your console
- freeze - deep freezes your state to prevent mutations
- actus-redux-devtools - use Redux DevTools Extension with actus
Other plugins that can be enabled manually:
- persist - persists state to a synchronous storage (
localStorage
by default) - actus-state-validator - state validator and normalizer powered by joi
Frameworks
Acknowledgements
Sources of inspiration:
Changelog
License
0.11.1-alpha.0
2 years ago
0.11.0-alpha.0
3 years ago
0.10.0-alpha.2
3 years ago
0.10.0-alpha.1
3 years ago
0.10.0-alpha.0
4 years ago
0.9.0-alpha.0
4 years ago
0.8.1-alpha.0
4 years ago
0.8.0-alpha.0
4 years ago
0.7.0-alpha.0
4 years ago
0.6.0-alpha.0
4 years ago
0.5.0-alpha.0
4 years ago
0.4.0-alpha.4
4 years ago
0.4.0-alpha.3
4 years ago
0.4.0-alpha.2
4 years ago
0.4.0-alpha.1
4 years ago
0.4.0-alpha.0
4 years ago
0.4.0-alpha.5
4 years ago
0.3.0-alpha.2
4 years ago
0.3.0-alpha.1
4 years ago
0.3.0-alpha.0
4 years ago
0.2.0-alpha.5
4 years ago
0.2.0-alpha.4
4 years ago
0.2.0-alpha.3
4 years ago
0.2.0-alpha.2
4 years ago
0.2.0-alpha.1
4 years ago
0.2.0-alpha.0
4 years ago
0.1.0-alpha.4
4 years ago
0.1.0-alpha.3
4 years ago
0.1.0-alpha.1
4 years ago
0.1.0-alpha.0
4 years ago
0.1.0-alpha.2
4 years ago
0.0.0-alpha.10
4 years ago
0.0.0-alpha.9
4 years ago
0.0.0-alpha.8
4 years ago
0.0.0-alpha.7
4 years ago
0.0.0-alpha.6
4 years ago
0.0.0
4 years ago
0.0.0-alpha.5
4 years ago
0.0.0-alpha.4
4 years ago
0.0.0-alpha.3
4 years ago
0.0.0-alpha.2
4 years ago
0.0.0-alpha.1
4 years ago