@async-resource/redux
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

@async-resource/redux

Installation

npm install --save @async-resource/redux

Usage

import connectResource, {
  consumeAction,
  reducers,
  registerResource,
  applyResourceToStore,
} from '@async-resource/redux'

// use it with https://github.com/ioof-holdings/redux-dynamic-reducer
// to add reducers dynamically
export const store = createStore(combineReducers({}))
const { registerResource: registerDynamicResource } = connectResource(store)
registerResource('user', {
  source: () => axios.get('/rest/user-info'),
})


// or use with a constant store
registerResource('user', {
  source: () => axios.get('/rest/user-info'),
})
export const store = createStore(combineReducers(reducers))
applyResourceToStore(store)


// interact with redux
store.dispatch(consumeAction('user'))

Package Sidebar

Install

npm i @async-resource/redux

Weekly Downloads

3

Version

0.2.1

License

MIT

Unpacked Size

31.3 kB

Total Files

11

Last publish

Collaborators

  • cristovao-trevisan