lynndylanhurley / j-toker

Simple, secure token authentication for jQuery.
Do What The F*ck You Want To Public License
173 stars 46 forks source link

PubSub events are not being triggered #10

Open nicolasiensen opened 9 years ago

nicolasiensen commented 9 years ago

Hey,

I'm trying to listen to j-toker events with PubSub, but it seems that no event is been triggered by j-toker.

I've tried to place this code

PubSub.subscribe('auth', function(data){
  console.log("auth");
});

And after calling Auth.emailSignIn, the PubSub auth was not triggered.

Thoughts?

nicolasiensen commented 9 years ago

Here is my hack to make it work.

colw commented 9 years ago

@nicolasiensen As an experiment, delete the pubsub-js dependency under j-toker, and install it directly into your own project.

nicolasiensen commented 9 years ago

Hey @colw, thanks for it, but we are not using j-toker anymore.

We had to move the project to a server-side rendering architecture, and since j-toker depends on client-side objects like window it was not possible to keep using it.

colw commented 9 years ago

@nicolasiensen Cool, no worries at all.

lynndylanhurley commented 9 years ago

Hi guys, I'm building out an isomorphic example app using j-toker and redux. I'll post back here when it's ready to show.

nicolasiensen commented 9 years ago

Awesome @lynndylanhurley, I'm also using redux :smiley:

lynndylanhurley commented 9 years ago

Cool, I'm thinking about releasing the redux wrapper as a separate project. I'm hoping to have it ready by the end of the week.

lynndylanhurley commented 9 years ago

Just a quick update, I have this working and I'm just writing the documentation. Stay tuned for a release.

jchristianhall commented 9 years ago

@lynndylanhurley Thanks so much for putting together a redux example! Can't wait to see it

lynndylanhurley commented 9 years ago

@jchristianhall - it's more than an example, it will be an entire library. I have it working and I'm just writing the tests now.

jchristianhall commented 9 years ago

@lynndylanhurley Excellent. Thanks!

jchristianhall commented 8 years ago

@lynndylanhurley Any word on when the redux library might be ready?

lynndylanhurley commented 8 years ago

@jchristianhall - sorry for the delay, I decided to add react-native support and it took a little longer than I thought. It should be a matter of days.

jchristianhall commented 8 years ago

@lynndylanhurley It's alright. Thanks for the update!

lynndylanhurley commented 8 years ago

@jchristianhall - the app is ready, please take a look: https://github.com/lynndylanhurley/redux-auth

aknott commented 8 years ago

had a similar issue here and used @nicolasiensen hack as a temp solution.

I noticed there were multiple PubSub instances and I was subscribing to an instance other than the one created within j-toker. When j-toker went to publish, that instance of PubSub had no subscribers. Potentially a side effect of webpack compilation as it appears both j-toker and pubsub-js are defining browser globals.