0
我用ReactiveVar延長訂閱當用戶訪問的網頁的結束,但我經歷了一些奇怪的行爲,最近(可能是因爲某些包的更新?)流星ReactiveVar行爲?
Template.hello.onCreated(function(){
var tpl = this;
tpl.dict = new ReactiveDict();
tpl.var = new ReactiveVar();
Session.set('session', undefined);
Tracker.autorun(function(){
console.log(tpl.dict.get('foo'), tpl.var.get(), Session.get('session'));
})
});
Template.hello.onRendered(function(){
var tpl = this;
console.log(this.dict.get('foo'), this.var.get(), Session.get('session'));
tpl.dict.set('foo', 'foo');
tpl.var.set('foo');
Session.set('session', 'foo');
});
這給:
undefined undefined undefined (onCreated)
undefined undefined undefined (onRendered)
foo foo foo (onCreated, after autorun)
我的基本問題是:這應該是正常的行爲? ReactiveVar/Dict在更改後不應該自動運行?
任何想法或我只是愚蠢? :)