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

Document the Flux dispatcher for non Flux users #126

Open
tanzim opened this issue Oct 14, 2016 · 1 comment
Open

Document the Flux dispatcher for non Flux users #126

tanzim opened this issue Oct 14, 2016 · 1 comment

Comments

@tanzim
Copy link

tanzim commented Oct 14, 2016

Hi,
We don't use Flux for our application, but still had to hook into it to receive stormpath events for login/logout etc.
While it wasn't a big deal, it required digging around the sources to see what evens were generated and how to get hold of the dispatcher itself. It would be nice if an example was provided?

In case someone else is wondering the same, what we ended up doing was something like this:

import stormpath, { context, constants } from 'react-stormpath';
// Initializing stormpath initializes the context, which has the dispatcher...
stormpath.init();
// Which is returned via getDispatcher on the context
var dispatcher = context.getDispatcher();
// And then use register to listen to events dispatched
dispatcher.register((data) => {
  const { options, type } = data;
  if (type === constants.USER_SET) {...}
});
@typerandom
Copy link
Contributor

Thank you for reporting this and awesome that you figured it out yourself!

This is definitely something we have overlooked and that we need to improve on.

I have tagged this as an enhancement, so once we have some time over we'll fix it! :)

Again, thanks and hope you have an awesome weekend!

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

No branches or pull requests

2 participants