ReduxService
class ReduxService
Returns a new instance of ReduxService, with following attributes and methods (this
is already binded):
const reduxService = new ReduxService()
middleware(store)
Middleware for Redux Store:
const store = Redux.createStore(reducer, Redux.applyMiddleware(reduxService.middleware))
setEntry(actionType, entryFunction)
Set an EntryFunction for Action Type. This takes effect on next dispatch.
reduxService.setEntry('entry:sample', (store, action) => {})
setService(serviceType, serviceGeneratorFunction)
Set an ServiceGeneratorFunction with a Service Type.
reduxService.setEntry('service:sample', function * ({ store, req, res }) {
let action = yield req('service:sample:one')
yield res({ type: 'reducer:sample:update', payload: session })
action = yield req([ 'service:sample:two', 'service:sample:three'])
yield res({ type: 'reducer:sample:update', payload: session })
})
Note: startService
or startAllService
must be called for the Service to accept Incoming Actions.
startService(serviceType)
Get the ServiceGenerator by Calling the ServiceGeneratorFunction with { store, req, res }
.
reduxService.startService('service:sample')
stopService(serviceType[, action])
First execute serviceGenerator.return(action)
, so if an Action is passed, the Service can process it (but no more yield)
Then the ServiceGenerator is discarded
reduxService.startService('service:sample')
startAllService()
Quick startService. Will skip already started Services.
reduxService.startAllService()