Skip to content

chesterkmr/ts-action-creator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published