javascript - Meteor.publish callback not being called -


i have simple project single meteor.publish call:

boxes = new meteor.collection("boxes");  if (meteor.isserver) {   meteor.startup(function () {     boxes.remove({}) //clearing database     boxes.insert({ //adding 1 element database       boxes: [1],       currentid: 1     });   });   console.log("publish1")   meteor.publish("boxes", function() {     console.log("publish2") //this not run! ever!     return boxes.find();   }); } 

for reason meteor.subscribe not seem working (the collections return empty), placed couple of console.log in code. reason server code prints "publish1" not print "publish2", while if try same in example project print both.

note: removed autopublish package.

you need subscribe on client. work me:

boxes = new meteor.collection("boxes");  if (meteor.isserver) {  meteor.startup(function () {   boxes.remove({}) //clearing database   boxes.insert({ //adding 1 element database     boxes: [1],     currentid: 1   }); }); console.log("publish1") meteor.publish("boxes", function() {     console.log("publish2") //this not run! ever!     return boxes.find();   }); }  if(meteor.isclient){    meteor.subscribe('boxes');  } 

the publish2 printed when open app in browser.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -