BundleCollection = {
_id : “ABC”,
list : [
{ id : 1, name: “John”},
{ id : 2, name: “Bob”},
{ id : 3, name: “Steve”}
]
}
PersonsCollection = {
{ _id : 1, name: “John”, Phone: 123}
{ _id : 2, name: “Bob”, Phone: 456}
{ _id : 3, name: “Steve”, Phone: 789}
{ _id : 4, name: “Christina”, Phone: 301}
}
var bPub = null;
Template.Bundle.onCreated(function() {
self = this;
self.autorun(function() {
bPub = self.subscribe(“bundlePub”, “ABC”);
if( bPub.ready()) {
// Build id list
// ids = array of id from bundle list
self.subscribe(“personPub”, ids);
}
});
});
Template.Bundle.helpers({
list: function() {
return PeronsCollection.find();
},
When I add { id : 4, name: “Christina”} into “ABC” document. The template renders all 4 people. But if I delete Christina right after I added her via click event -> meteor.call, personPub subscription is empty. When I debug, the “list” helper is triggered twice. The fist run, Christina is removed, the second, PersonsCollection.find() return empty.
However, if I add Christina, go to a different route and come back, I can delete Christina without any issue. I don’t understand why “list” helper is triggered twice, and why it return empty list. Thanks in advance.