inst-redux-service-middleware

20.11.2 • Public • Published
  1. While creating your store, register your services as key/value pairs with the service middleware constructor:
  applyMiddleware(
    createServiceMiddleware({
      myKey: myService,
      myOtherKey: myOtherService
    })
  )
  1. In your action creator, dispatch an action with the following shape:
  {
    type: serviceMiddleware.CALL_SERVICE
    payload: {
      service: 'myKey'
      method: 'methodName'
      args: [arg1, arg2]
    }
  }

Subsequent calls to dispatch with your action creator will return the result of calling myService.methodName(arg1, arg2)

Dependents (1)

Package Sidebar

Install

npm i inst-redux-service-middleware

Weekly Downloads

7,649

Version

20.11.2

License

MIT

Unpacked Size

45.3 kB

Total Files

15

Last publish

Collaborators

  • maths22
  • skacsmark
  • jcrystal
  • quizzesuici
  • omarkhan
  • scientistryan
  • mbrewerdavis