我有一个模型,我用来自服务器的数据填充。问题是,当最初填充该数据时,我的订阅正在触发,这是我不想要的。我只希望在用户与 UI 交互时触发订阅。
function ViewModel() {
var self = this;
//Populate the object.
self.request = new Request(data);
//Subscribe to one of the "properties" so that I can do stuff when the value changes.
self.request.selectedId.subscribe(function(newValue) {
//This is firing before the user interacts with the UI.
});
}