Legitcode/actions

Name: actions

Owner: Legitcode

Description: helper function that injects redux actions

Created: 2016-02-15 05:12:23.0

Updated: 2016-02-15 05:12:46.0

Pushed: 2017-11-18 19:07:19.0

Homepage: null

Size: 5

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

legit actions
WIP

This is a utility for injecting actions in redux. The idea came from having a huge project with actions all over the place. What if we treated actions like routes and made a file with a list of them?

Create actions.config.js

In the root of your project

rt const todos = require('./todos/actions')
rt const posts = require('./posts/actions')

This file has a list of your different actions. This helps organize where things are in your project.

Inject some actions!
rt { actions } from 'legit-actions'

t Todos = ({ dispatch, items, newItem }) => (
iv>
First Item: {items[0]}
<input 
  onKeyDown={e => e.keyCode == 13 && dispatch(newItem(e.target.value))} 
/>
div>


rt default connect(state => ({items: state}))(actions('todos')(Todos))

You can use this as a decorator too if you want! The value passed in to the actions function is the name of an export from the config file. It will inject all actions as props for you.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.