Browse Source

支持BI.useContext

es6
guy 3 years ago
parent
commit
45a9352c42
  1. 20
      src/core/4.widget.js

20
src/core/4.widget.js

@ -773,34 +773,40 @@
};
BI.watch = function (vm, watch, handler) {
if (BI.Widget.current) {
if (vm instanceof BI.Model) {
BI.Widget.current._watchers || (BI.Widget.current._watchers = []);
var watchers = [];
if (BI.isKey(watch)) {
var k = watch;
watch = {};
watch[k] = handler;
}
for (var key in watch) {
var handler = watch[key];
var innerHandler = watch[key];
if (BI.isArray(handler)) {
for (var i = 0; i < handler.length; i++) {
BI.Widget.current._watchers.push(Fix.watch(vm.model, key, handler, {
watchers.push(Fix.watch(vm.model, key, innerHandler, {
store: vm
}));
}
} else {
BI.Widget.current._watchers.push(Fix.watch(vm.model, key, handler, {
watchers.push(Fix.watch(vm.model, key, innerHandler, {
store: vm
}));
}
}
} else {
if (vm._widget) {
vm._widget._watchers || (vm._widget._watchers = []);
vm._widget._watchers = vm._widget._watchers.concat(watchers);
}
return;
}
if (BI.Widget.current) {
handler = watch;
watch = vm;
BI.Widget.current.$watchDelayCallbacks || (BI.Widget.current.$watchDelayCallbacks = []);
BI.Widget.current.$watchDelayCallbacks.push([watch, handler]);
}
}
};

Loading…
Cancel
Save