Hi,
Using a method i get data and present iT on a page, from external datasource
Using a button i delete something using a method and as such I update This external datasource
Now, my page is out of sync, it shows too much (the deleted item is stil shown)
What is the best way to make this reactive?
- create a dummy var like favoriteFoodDep that i use to make the tracker run?
- in my tracker.autorun code i Will Call my method to get the external data again and store this in a session var
Example code
var favoriteFood = “apples”;
var favoriteFoodDep = new Tracker.Dependency;
var getFavoriteFood = function () {
favoriteFoodDep.depend();
return favoriteFood;
};
var setFavoriteFood = function (newValue) {
favoriteFood = newValue;
favoriteFoodDep.changed();
};
getFavoriteFood();
// “apples”
var handle = Tracker.autorun(function () {
console.log("Your favorite food is " + getFavoriteFood());
// in my case:
meteor.call(getData) and store result in session var?
});