【发布时间】:2017-10-12 06:53:20
【问题描述】:
我想知道我的发布和订阅实现是否正确。我是流星js的新手,请帮助我。如果您需要有关我的代码的更多信息,我愿意为您提供其他源代码。我阅读了有关发布和订阅的文档,但我不了解有关它的文档。
import { Mongo } from 'meteor/mongo';
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
export const Notes = new Mongo.Collection('notes');
if(Meteor.isServer) {
Meteor.publish('secureData', function() {
return Notes.find({});
});
}
if(Meteor.isClient) {
Meteor.subscribe('secureData');
}
【问题讨论】:
-
把你的代码放在这里而不是在图像中。
-
我将您的代码直接添加到帖子中并省略了不必要的行。如果您将代码直接放入您的帖子中,下次您将获得更少的反对票。 :)
标签: javascript meteor publish subscribe