1.0.14 • Published 2 years ago

surendar-yama-joy v1.0.14

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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)
1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago