surendar-yama-joy
TypeScript icon, indicating that this package has built-in type declarations

1.0.14 • Public • Published

surendar-yama-joy

surendar-yama-joy library allow you to use joyReducer hook in javascript for both client and server side.

npm i surendar-yama-joy

In client side please use any build tool like parceljs

Commonjs module import

const { joyReducer } = require("surendar-yama-joy");

ES Module import

import { joyReducer } from "surendar-yama-joy"

const onDomContentLoaded = () => {
    const initialState = {
        count:0
    };
    const reducerFn = (state, action) => {
            switch(action.type){
                case 'increment':
                    return { ...state, count: state.count + 1 }
                case 'decrement':
                    return { ...state, count: state.count - 1 }
                default:
                    return state
            }
    }
   
    const [getState, dispatch] = joyReducer(initialState , reducerFn);

    console.log(getState())
    dispatch({
        type :"increment",
    })
    console.log(getState())
    dispatch({
        type :"increment",
    })
    console.log(getState())
    dispatch({
        type :"decrement",
    })
    console.log(getState())

}
document.addEventListener("DOMContentLoaded", onDomContentLoaded)

/surendar-yama-joy/

    Package Sidebar

    Install

    npm i surendar-yama-joy

    Weekly Downloads

    0

    Version

    1.0.14

    License

    ISC

    Unpacked Size

    3.08 kB

    Total Files

    5

    Last publish

    Collaborators

    • surendar_yama