Skip to content

Latest commit

 

History

History
68 lines (48 loc) · 2.05 KB

README.md

File metadata and controls

68 lines (48 loc) · 2.05 KB

redux-trivial-actions utility library by Brainbean Apps

Build Status Coverage Status npm version Dependency Status Maintainability JavaScript Style Guide MIT license

NPM

Objectified Flux Standard Action for Redux.

Getting Started

Installation

$ npm install --save redux-trivial-actions

or

$ yarn add redux-trivial-actions

Usage

actions.js

import { createTrivialAction } from 'redux-trivial-actions'

export const demoAction = createTrivialAction('DEMO_ACTION')

reducer.js

import { demoAction } from './actions'

const initialState = { demoValue: false }

const reducer = (state = initialState, action) => {
  switch (action.type) {
    case demoAction.PERFORM:
      return { ...state, demoValue: true }
    default:
      return state
  }
}

export default reducer;

component.js

import { demoAction } from './actions'

// ...
dispatch(demoAction.perform())
// or
dispatch(demoAction())
// ...