|
|
@ -7,7 +7,7 @@ import { |
|
|
|
extend, |
|
|
|
extend, |
|
|
|
isFunction, |
|
|
|
isFunction, |
|
|
|
Widget, |
|
|
|
Widget, |
|
|
|
Providers |
|
|
|
Providers, emptyFn |
|
|
|
} from "@/core"; |
|
|
|
} from "@/core"; |
|
|
|
import { Fix } from "./fix"; |
|
|
|
import { Fix } from "./fix"; |
|
|
|
|
|
|
|
|
|
|
@ -76,7 +76,7 @@ function popTarget() { |
|
|
|
export const Model = Fix.Model; |
|
|
|
export const Model = Fix.Model; |
|
|
|
|
|
|
|
|
|
|
|
const oldWatch = Fix.watch; |
|
|
|
const oldWatch = Fix.watch; |
|
|
|
Fix.watch = function (model, expOrFn, cb, options) { |
|
|
|
Fix.watch = function(model, expOrFn, cb, options) { |
|
|
|
if (isPlainObject(cb)) { |
|
|
|
if (isPlainObject(cb)) { |
|
|
|
options = cb; |
|
|
|
options = cb; |
|
|
|
cb = cb.handler; |
|
|
|
cb = cb.handler; |
|
|
@ -89,7 +89,7 @@ Fix.watch = function (model, expOrFn, cb, options) { |
|
|
|
this, |
|
|
|
this, |
|
|
|
model, |
|
|
|
model, |
|
|
|
expOrFn, |
|
|
|
expOrFn, |
|
|
|
function () { |
|
|
|
function() { |
|
|
|
options && options.store && pushTarget(options.store); |
|
|
|
options && options.store && pushTarget(options.store); |
|
|
|
let res; |
|
|
|
let res; |
|
|
|
try { |
|
|
|
try { |
|
|
@ -167,7 +167,7 @@ export function createStore() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const _init = Widget.prototype._init; |
|
|
|
const _init = Widget.prototype._init; |
|
|
|
Widget.prototype._init = function () { |
|
|
|
Widget.prototype._init = function() { |
|
|
|
const needPop = createStore.call(this); |
|
|
|
const needPop = createStore.call(this); |
|
|
|
try { |
|
|
|
try { |
|
|
|
_init.apply(this, arguments); |
|
|
|
_init.apply(this, arguments); |
|
|
@ -178,7 +178,7 @@ Widget.prototype._init = function () { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const __initWatch = Widget.prototype.__initWatch; |
|
|
|
const __initWatch = Widget.prototype.__initWatch; |
|
|
|
Widget.prototype.__initWatch = function () { |
|
|
|
Widget.prototype.__initWatch = function() { |
|
|
|
__initWatch.apply(this, arguments); |
|
|
|
__initWatch.apply(this, arguments); |
|
|
|
const workerMode = |
|
|
|
const workerMode = |
|
|
|
Providers.getProvider("bi.provider.system").getWorkerMode(); |
|
|
|
Providers.getProvider("bi.provider.system").getWorkerMode(); |
|
|
@ -191,7 +191,7 @@ Widget.prototype.__initWatch = function () { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const unMount = Widget.prototype.__destroy; |
|
|
|
const unMount = Widget.prototype.__destroy; |
|
|
|
Widget.prototype.__destroy = function () { |
|
|
|
Widget.prototype.__destroy = function() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
unMount.apply(this, arguments); |
|
|
|
unMount.apply(this, arguments); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
@ -213,10 +213,29 @@ Widget.prototype.__destroy = function () { |
|
|
|
delete this.__cacheStore; |
|
|
|
delete this.__cacheStore; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Widget.prototype.__watch = function(getter, handler, options) { |
|
|
|
|
|
|
|
this._watchers = this._watchers || []; |
|
|
|
|
|
|
|
const watcher = new Fix.Watcher( |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
() => getter.call(this, this), |
|
|
|
|
|
|
|
(handler && |
|
|
|
|
|
|
|
((v) => { |
|
|
|
|
|
|
|
handler.call(this, this, v); |
|
|
|
|
|
|
|
})) || |
|
|
|
|
|
|
|
emptyFn, |
|
|
|
|
|
|
|
extend({ deep: true }, options) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
this._watchers.push(() => { |
|
|
|
|
|
|
|
watcher.teardown(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return watcher.value; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
_.each(["_render", "__afterRender", "_mount", "__afterMount"], (name) => { |
|
|
|
_.each(["_render", "__afterRender", "_mount", "__afterMount"], (name) => { |
|
|
|
const old = Widget.prototype[name]; |
|
|
|
const old = Widget.prototype[name]; |
|
|
|
old && |
|
|
|
old && |
|
|
|
(Widget.prototype[name] = function () { |
|
|
|
(Widget.prototype[name] = function() { |
|
|
|
this.store && pushTarget(this.store); |
|
|
|
this.store && pushTarget(this.store); |
|
|
|
let res; |
|
|
|
let res; |
|
|
|
try { |
|
|
|
try { |
|
|
|