This PR exports all the action types used by the reduxified services, and put them in the types field.
const services = reduxifyServices(app, ['messages']);
console.log(services.types);
// Will output:
{
SERVICES_MESSAGES_FIND: 'SERVICES_MESSAGES_FIND',
SERVICES_MESSAGES_FIND_PENDING: 'SERVICES_MESSAGES_FIND_PENDING',
SERVICES_MESSAGES_FIND_FULFILLED: 'SERVICES_MESSAGES_FIND_FULFILLED',
SERVICES_MESSAGES_FIND_REJECTED: 'SERVICES_MESSAGES_FIND_REJECTED',
// ... same for CREATE, GET etc
}
Why is this useful?
In some apps, it might be useful to listen to actions dispatched by feathers-redux, for example for managing side-effects.
Right now, to listen to actions dispatched by feathers-redux, we listen to the string directly. An example with redux-saga would be: yield take('SERVICES_MESSAGES_CREATE_FULFILLED', doSomethingSaga);
After this PR, it would be yield take(services.types.SERVICES_MESSAGES_CREATE_FULFILLED, doSomethingSaga)
The big advantage is to avoid putting raw strings everywhere in the code (bad practice).
Summary
This PR exports all the action types used by the reduxified services, and put them in the
types
field.Why is this useful?
In some apps, it might be useful to listen to actions dispatched by feathers-redux, for example for managing side-effects.
Right now, to listen to actions dispatched by feathers-redux, we listen to the string directly. An example with redux-saga would be:
yield take('SERVICES_MESSAGES_CREATE_FULFILLED', doSomethingSaga);
After this PR, it would be
yield take(services.types.SERVICES_MESSAGES_CREATE_FULFILLED, doSomethingSaga)
The big advantage is to avoid putting raw strings everywhere in the code (bad practice).
Other Information
If this is useful, I'll update some docs too.