inst-redux-service-middleware

20.11.4 • 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)

/inst-redux-service-middleware/

    Package Sidebar

    Install

    npm i inst-redux-service-middleware

    Weekly Downloads

    9,336

    Version

    20.11.4

    License

    MIT

    Unpacked Size

    45.6 kB

    Total Files

    15

    Last publish

    Collaborators

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