Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

brainbeanapps/redux-trivial-actions

Repository files navigation

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())
// ...