1.2.3 • Published 4 years ago

redux-soldier v1.2.3

Weekly downloads
23
License
MIT
Repository
github
Last release
4 years ago

GitHub Multipack

Getting started

npm install redux-soldier

Then, to enable redux-soldier, use applyMiddleware():

import { createStore, applyMiddleware } from 'redux'
import { reduxSoldierMiddleware } from 'redux-soldier'
import rootReducer from './reducers'

const store = createStore(rootReducer, applyMiddleware(reduxSoldierMiddleware))

What can redux-soldier

It can dispatch thunk actions, if provided argument is a function. In this case works same as redux-thunk

dispatch(fetchUser()) // thunk action

// also it can dispatch multiple thunk actions

dispatch([
  fetchUser(), // thunk action
  fetchUserWishList(), // thunk action
])

It can dispatch multiple actions, if provided argument is an array of actions.

dispatch([
  addToDo('Learn how to use redux-soldier 👨🏼‍✈️'), // traditional action creator
  { type: 'INCREMENT' }, // traditional action
])

It can dispatch multiple mixed actions, if provided argument is an array of actions.

dispatch([
  fetchUser(), // thunk action
  addToDo('Learn how to use redux-soldier 👨🏼‍✈️'), // traditional action creator
  { type: 'INCREMENT' }, // traditional action
])

It can return a promise or array of promises if provided argument is a async thunk action or an array of thunk actions.

Note: if is provided an array of mixed actions it returns only an array of thunk actions promises

dispatch(fetchUser()).then(response => {
  /* do stuff */
})

// or multiple thunc actions

dispatch([
  fetchUser(), // thunk action
  fetchUserWishList(), // thunk action
]).forEach(promise => {
  promise.then(response => {
    // do stuff
  })
})

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Or you can sponsor via Open Collective

Open Collective

Author

@Gherciu/redux-soldier © GHERCIU, Released under the MIT License. Authored and maintained by GHERCIU with help from contributors (list).

If you like this repository star⭐ and watch👀 on GitHub

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago