Skip to content

Latest commit

 

History

History
34 lines (19 loc) · 695 Bytes

README.md

File metadata and controls

34 lines (19 loc) · 695 Bytes

ts-action-creator

ts-action-creator simple library which will let you create typed actions for reducers.

Install

npm i --save ts-action-creator

Usage Example

import {makeAction} from 'ts-action-creator'

const myTypedAction = makeAction<{value : string}>('MY_TYPED_ACTION_NAME'); // creating action


// will be dispatched as {type : 'MY_TYPED_ACTION_NAME' , payload : {value : 'value'}}
dispatch(myTypedAction({value : "my value"})); 


function reducer(state = {} , action : Action) {
    if(myTypedAction.match(action)) { // Usage in reducer
        return state;
    }
}

Action Properties

createdAction.type // Contains action type