0
我有一個流星包內的工作,在一個js文件的全局函數通過我添加api.addFiles
:流星包:Session.set並不
showLayer = function(id) {
var layers = Session.get('layers');
layers[id] = true;
Session.set('layers', layers);
// just for testing - check if it worked
var tmpLayers = Session.get('layers');
alert('layers.id:' + layers[id] + ' tmpLayers.id:' + tmpLayers[id]);
window.setTimeout(function() {
var tmpLayers = Session.get('layers');
alert('layers.id:' + layers[id] + ' tmpLayers.id:' + tmpLayers[id]);
}, 1000);
};
注意,setTimeout
我只使用給Session
有些時候如果應該有一些優化來延緩這種變化。結果是layers[id]
被設置爲應該的,但tmpLayers[id]
不是,延遲測試,並在set
之後。
不管我檢查通過setTimeout
或右延遲到位內部功能:該Session.set
線似乎並沒有做任何東西無論如何!
請注意,這不是沒有發生反應的問題 - 或者至少我不會看到如何。
您是否在'package.js'中添加了'api.use('session');'? –
不幸的是 - 我正在使用'session'和'meteor-platform',它應該包括所有其他的。我現在還添加了上面的非延遲測試代碼來澄清。 –