In Meteor, how do you detect when a new user is logged in?

Documentation:

http://docs.meteor.com/#publish_userId

He speaks

This is a constant value. However, if the user is logged in, the publication function re-starts with the new value.

Is there any way to run any event-driven code that only fires on an event that a registered user has changed?

+8
meteor
source share
3 answers

Meteor.user() , Meteor.userId() and Meteor.userLoaded() are all reactive data sources ( documentation ).

If you place them inside the template helper or create your own context around them, you will notice when the current user changes.

+11
source share

You can also do this through Subscription, and you can track the user and register inside the server. See my blog

Go to the code section in the blog post.

+1
source share

{{#if currentUser}} may work for you in your template.

0
source share

All Articles