Hullo JS


import { Redux } from '@hullo/core'
Redux is created with a set of reducers and initial state. Reducers are put into an object where keys are action tags and properties are reducing functions. Each said function will receive a state and action payload (not whole action) and should return new state (optionally - asynchronously, with a Promise).
Redux, like Atom, has unwrap method that allows for synchronous access to stored value.
Redux::next should be provided with an object of shape:
action: ACTION,
Consider this example:
const redux = new Redux(
addNumber(state, data: number) {
return { state: [...state, data] };
async addString(state, data: string) {
return {
state: [...state, data],
effects: [
{ type: "success", data: null }
success(state) {
// this is just for demonstration sake
// you should try to make actions without side-effects
console.log("🎉 success!");
return state;
new Array<string | number>()
await{ type: "addNumber", data: 0 });
// redux.unwrap() is [0]
await{ type: "addString", data: "a" });
// redux.unwrap() is [0, "a"]
Last modified 2yr ago