- While creating your store, register your services as key/value pairs with the service middleware constructor:
applyMiddleware(
createServiceMiddleware({
myKey: myService,
myOtherKey: myOtherService
})
)
- 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)