Meteor 如何在各处发布和订阅用户日志数据?

How to Meteor publish & subscribe the user logining data in everywhere?

有人可以帮助我吗?我对 Meteor 有疑问,如何保持用户登录的数据可以在任何地方发布和订阅? 我创建了一个类似于 Meteor 的 Users 集合的集合,并编写了另一个登录函数,但是在用户登录后,我无法在任何地方保留他们的数据订阅。 对不起,我英语不好! 非常感谢!

试试这个:

import { Meteor } from 'meteor/meteor';

Meteor.publish(null, function userData() {
    if (!this.userId) {
        return this.ready();
    }
    return Meteor.users.find(this.userId);
});

谢谢大家,我找到了答案。似乎流星使用 HTML5 localStorage enter image description here

如果用户已登录,您可以在代码中的任何位置调用 Meteor.user() 来访问用户对象。