【发布时间】:2016-03-02 17:11:19
【问题描述】:
我正在尝试调用 Meteor 方法,而不是使用硬编码字符串,而是使用包含其名称的 Session 变量。当Session 值通过Session.set 更改时,它只工作一次,但不会重新运行该方法。
服务器代码:
Meteor.methods({
hello: function () {
console.log("hello");
},
hi: function () {
console.log("hi");
}
});
客户端代码:
Session.set('say', 'hi');
Meteor.call(Session.get('say')); // console prints hi
Session.set('say', 'hello'); // console is not printing, expected hello
如何在 Session 值更改后响应式地调用“新”方法?
【问题讨论】:
标签: javascript meteor meteor-methods