1.0.14 • Published 10 months ago

surendar-yama-joy v1.0.14

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months 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

10 months ago

1.0.13

10 months ago

1.0.12

10 months ago

1.0.11

10 months ago

1.0.10

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago