nibzbstx

1.0.0 • Public • Published

Welcome to nibzbstx 👋

Version License: MIT

Simple and reusable state management system with side effects

Install

yarn add nibzbstx

or

npm install nibzbstx

Usage

Chainable

import {getActionHOC} from "../helpers/nibzbstm/actions";
import {State, generateStore, Actions} from "../helpers/nibzbstm/index";

const makeBtnTrue = (state, payload) => {
    return {...state,btn: true};
};
const makeBtnFalse = (state, payload) => {
    return {...state,btn: false};
};
const makeBtn2True = (state, payload) => {
    return {...state,btn2: true};
};
const makeBtn2False = (state, payload) => {
    return {...state, btn2: false};
};
const changeBtn3State = (state, payload) => {
    return {...state, btn3: payload};
};
$(document).ready(() => {
    const btnAction = State({
        initial: {btn: false},
        makeBtnTrue,
        makeBtnFalse
    });
    const btnAction2 = State({
        initial: {btn2: false},
        makeBtn2True,
        makeBtn2False
    });
    const btnAction3 = State({
        initial: {btn3: false},
        changeBtn3State
    });

    const store = generateStore(btnAction, btnAction2, btnAction3);

    store.manageEffects(function () {
        console.log("changed");
    }, ["btn","btn3"]);

    console.log(store.getState());
    store.actions.makeBtnTrue();
    console.log(store.getState());
    store.actions.makeBtn2True();
    console.log(store.getState());
    store.actions.changeBtn3State(false);
    console.log(store.getState());

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

Readme

Keywords

Package Sidebar

Install

npm i nibzbstx

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

132 kB

Total Files

17

Last publish

Collaborators

  • zblash