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',它应该包括所有其他的。我现在还添加了上面的非延迟测试代码来澄清。 –