Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export action types #29

Merged
merged 2 commits into from Aug 23, 2017
Merged

Export action types #29

merged 2 commits into from Aug 23, 2017

Conversation

amaury1093
Copy link
Contributor

Summary

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).

Other Information

If this is useful, I'll update some docs too.

@eddyystop
Copy link
Collaborator

I guess this repo is reaching some level of maturity. :) Thanks.

I'll merge it with your PR for the docs. No use having "hidden" features.

@eddyystop eddyystop mentioned this pull request Aug 23, 2017
@amaury1093
Copy link
Contributor Author

@eddyystop Ready to be merged.

@eddyystop eddyystop merged commit 2ad5b07 into feathersjs-ecosystem:master Aug 23, 2017
@eddyystop
Copy link
Collaborator

Thanks!

@eddyystop
Copy link
Collaborator

Published as v1.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants