Browse Source

webworker

es6
guy 4 years ago
parent
commit
5fdbc797bb
  1. 10
      dist/fix/worker.compact.js

10
dist/fix/worker.compact.js vendored

@ -39,7 +39,6 @@
var unMount = BI.Widget.prototype.__d; var unMount = BI.Widget.prototype.__d;
BI.Widget.prototype.__d = function () { BI.Widget.prototype.__d = function () {
delete contexts[this.getName()];
this.$destroyWorker && this.$destroyWorker(); this.$destroyWorker && this.$destroyWorker();
try { try {
unMount.apply(this, arguments); unMount.apply(this, arguments);
@ -61,12 +60,18 @@
if (this._worker) { if (this._worker) {
var name = this.getName(); var name = this.getName();
var modelType = this._worker(); var modelType = this._worker();
var options;
if (BI.isArray(modelType)) {
options = modelType[1];
modelType = modelType[0];
}
if (WORKER) { if (WORKER) {
contexts[name] = this; contexts[name] = this;
WORKER.postMessage({ WORKER.postMessage({
type: modelType, type: modelType,
name: name, name: name,
eventType: "create", eventType: "create",
options: options,
watches: BI.map(this.watch, function (key) { watches: BI.map(this.watch, function (key) {
return key; return key;
}) })
@ -89,6 +94,7 @@
} }
}); });
return function () { return function () {
delete contexts[name];
WORKER.postMessage({ WORKER.postMessage({
type: modelType, type: modelType,
name: name, name: name,
@ -96,7 +102,7 @@
}); });
}; };
} else { } else {
this.store = BI.Models.getModel(modelType); this.store = BI.Models.getModel(modelType, options);
this.store && (this.store._widget = this); this.store && (this.store._widget = this);
if (this.store instanceof Fix.Model) { if (this.store instanceof Fix.Model) {
this.model = this.store.model; this.model = this.store.model;

Loading…
Cancel
Save