mat

magic-action-types

✨ Magical Action Types (for Flux, Redux, etc)

Showing:

Popularity

Downloads/wk

0

GitHub Stars

3

Maintenance

Last Commit

5mos ago

Contributors

2

Package

Dependencies

0

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

✨ Magical ✨ Action Types (for Flux, Redux, etc)

But why tho?

This is annoying.

const INCREMENT = 'app/counter/INCREMENT'
const DECREMENT = 'app/counter/DECREMENT'

This is weird.

const types = keyMirror({
  INCREMENT: null,
  DECREMENT: null,
})

But this is ✨ magical ✨

const { INCREMENT, DECREMENT } = types('app/counter')

Usage

npm install magic-action-types

Use object destructuring to simplify your action type definitions.

import types from 'magic-action-types'

const { INCREMENT, DECREMENT } = types()
// INCREMENT === "INCREMENT"
// DECREMENT === "DECREMENT"

Pass a namespace to the types function.

const { INCREMENT, DECREMENT } = types('app/counter')
// INCREMENT === "app/counter/INCREMENT"
// DECREMENT === "app/counter/DECREMENT"

Go ahead, save your namespace too.

const counterTypes = types('app/counter')

const { INCREMENT, DECREMENT } = counterTypes
// INCREMENT === "app/counter/INCREMENT"
// DECREMENT === "app/counter/DECREMENT"

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial