Add support for async store when WebWorker is not available

This commit is contained in:
yflory
2018-06-12 18:20:48 +02:00
parent e39c77e162
commit 1b49020753
2 changed files with 24 additions and 4 deletions

View File

@@ -9,7 +9,17 @@ define([
};
var create = function (onMsg, postMsg, cb, isWorker) {
if (!isWorker) {
var chanLoaded = false;
var waitingData = [];
onMsg.reg(function (data) {
if (chanLoaded) { return; }
waitingData.push(data);
});
}
var evReady = Util.mkEvent(true);
var handlers = {};
var queries = {};
@@ -123,6 +133,12 @@ define([
});
if (isWorker) {
evReady.fire();
} else {
chanLoaded = true;
waitingData.forEach(function (d) {
onMsg.fire(d);
});
waitingData = [];
}
cb(chan);
};