Skip to content

Commit

Permalink
Fixing load() by not sending the data right back into the adapters
Browse files Browse the repository at this point in the history
Missed a spot ;P
  • Loading branch information
avoidwork committed Jul 28, 2015
1 parent 56c2001 commit e2fdf4f
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 45 deletions.
32 changes: 17 additions & 15 deletions lib/haro.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @copyright 2015
* @license BSD-3-Clause
* @link http://haro.rocks
* @version 1.5.0
* @version 1.5.1
*/
"use strict";

Expand Down Expand Up @@ -201,7 +201,7 @@ class Haro {
}
}

batch (args, type) {
batch (args, type, lload = false) {
let defer = deferred(),
del = type === "del",
data, fn, hash;
Expand All @@ -220,7 +220,7 @@ class Haro {
};
} else {
fn = i => {
return this.set(null, i, true, true);
return this.set(null, i, true, true, lload);
};
}

Expand Down Expand Up @@ -463,7 +463,7 @@ class Haro {
console.log("Loaded", id, "from", type, "persistent storage");
}

return batch ? this.batch(arg, "set") : this.set(key, arg);
return batch ? this.batch(arg, "set", true) : this.set(key, arg, true, true, true);
}, e => {
if (this.logging) {
console.error("Error loading", id, "from", type, "persistent storage:", (e.message || e.stack || e));
Expand Down Expand Up @@ -598,7 +598,7 @@ class Haro {
return tuple.apply(tuple, result);
}

set (key, data, batch = false, override = false) {
set (key, data, batch = false, override = false, lload = false) {
let defer = deferred(),
method = "post",
ldata = clone(data),
Expand Down Expand Up @@ -641,15 +641,17 @@ class Haro {
setIndex(this.index, this.indexes, this.delimiter, lkey, ldata);
defer.resolve(this.get(lkey));

this.storage("set", lkey, ldata).then(success => {
if (success && this.logging) {
console.log("Saved", lkey, "to persistent storage");
}
}, e => {
if (this.logging) {
console.error("Error saving", lkey, "to persistent storage:", (e.message || e.stack || e));
}
});
if (!lload) {
this.storage("set", lkey, ldata).then(success => {
if (success && this.logging) {
console.log("Saved", lkey, "to persistent storage");
}
}, e => {
if (this.logging) {
console.error("Error saving", lkey, "to persistent storage:", (e.message || e.stack || e));
}
});
}
};

if (lkey === undefined || lkey === null) {
Expand Down Expand Up @@ -918,7 +920,7 @@ function factory (data = null, config = {}, indexes = []) {
return new Haro(data, config, indexes);
}

factory.version = "1.5.0";
factory.version = "1.5.1";

// Node, AMD & window supported
if (typeof exports !== "undefined") {
Expand Down
34 changes: 20 additions & 14 deletions lib/haro.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @copyright 2015
* @license BSD-3-Clause
* @link http://haro.rocks
* @version 1.5.0
* @version 1.5.1
*/
"use strict";

Expand Down Expand Up @@ -223,6 +223,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
value: function batch(args, type) {
var _this2 = this;

var lload = arguments[2] === undefined ? false : arguments[2];

var defer = deferred(),
del = type === "del",
data = undefined,
Expand All @@ -243,7 +245,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
};
} else {
fn = function (i) {
return _this2.set(null, i, true, true);
return _this2.set(null, i, true, true, lload);
};
}

Expand Down Expand Up @@ -516,7 +518,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
console.log("Loaded", id, "from", type, "persistent storage");
}

return batch ? _this5.batch(arg, "set") : _this5.set(key, arg);
return batch ? _this5.batch(arg, "set", true) : _this5.set(key, arg, true, true, true);
}, function (e) {
if (_this5.logging) {
console.error("Error loading", id, "from", type, "persistent storage:", e.message || e.stack || e);
Expand Down Expand Up @@ -670,10 +672,12 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
}, {
key: "set",
value: function set(key, data) {
var batch = arguments[2] === undefined ? false : arguments[2];

var _this9 = this;

var batch = arguments[2] === undefined ? false : arguments[2];
var override = arguments[3] === undefined ? false : arguments[3];
var lload = arguments[4] === undefined ? false : arguments[4];

var defer = deferred(),
method = "post",
Expand Down Expand Up @@ -718,15 +722,17 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
setIndex(_this9.index, _this9.indexes, _this9.delimiter, lkey, ldata);
defer.resolve(_this9.get(lkey));

_this9.storage("set", lkey, ldata).then(function (success) {
if (success && _this9.logging) {
console.log("Saved", lkey, "to persistent storage");
}
}, function (e) {
if (_this9.logging) {
console.error("Error saving", lkey, "to persistent storage:", e.message || e.stack || e);
}
});
if (!lload) {
_this9.storage("set", lkey, ldata).then(function (success) {
if (success && _this9.logging) {
console.log("Saved", lkey, "to persistent storage");
}
}, function (e) {
if (_this9.logging) {
console.error("Error saving", lkey, "to persistent storage:", e.message || e.stack || e);
}
});
}
};

if (lkey === undefined || lkey === null) {
Expand Down Expand Up @@ -1037,7 +1043,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
return new Haro(data, config, indexes);
}

factory.version = "1.5.0";
factory.version = "1.5.1";

// Node, AMD & window supported
if (typeof exports !== "undefined") {
Expand Down
2 changes: 1 addition & 1 deletion lib/haro.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/haro.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "haro",
"version": "1.5.0",
"version": "1.5.1",
"description": "Harō is a modern immutable DataStore using Maps, Sets, Promises, & Tuples",
"main": "lib/haro.js",
"scripts": {
Expand Down
28 changes: 15 additions & 13 deletions src/haro.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Haro {
}
}

batch (args, type) {
batch (args, type, lload = false) {
let defer = deferred(),
del = type === "del",
data, fn, hash;
Expand All @@ -54,7 +54,7 @@ class Haro {
};
} else {
fn = i => {
return this.set(null, i, true, true);
return this.set(null, i, true, true, lload);
};
}

Expand Down Expand Up @@ -297,7 +297,7 @@ class Haro {
console.log("Loaded", id, "from", type, "persistent storage");
}

return batch ? this.batch(arg, "set") : this.set(key, arg);
return batch ? this.batch(arg, "set", true) : this.set(key, arg, true, true, true);
}, e => {
if (this.logging) {
console.error("Error loading", id, "from", type, "persistent storage:", (e.message || e.stack || e));
Expand Down Expand Up @@ -432,7 +432,7 @@ class Haro {
return tuple.apply(tuple, result);
}

set (key, data, batch = false, override = false) {
set (key, data, batch = false, override = false, lload = false) {
let defer = deferred(),
method = "post",
ldata = clone(data),
Expand Down Expand Up @@ -475,15 +475,17 @@ class Haro {
setIndex(this.index, this.indexes, this.delimiter, lkey, ldata);
defer.resolve(this.get(lkey));

this.storage("set", lkey, ldata).then(success => {
if (success && this.logging) {
console.log("Saved", lkey, "to persistent storage");
}
}, e => {
if (this.logging) {
console.error("Error saving", lkey, "to persistent storage:", (e.message || e.stack || e));
}
});
if (!lload) {
this.storage("set", lkey, ldata).then(success => {
if (success && this.logging) {
console.log("Saved", lkey, "to persistent storage");
}
}, e => {
if (this.logging) {
console.error("Error saving", lkey, "to persistent storage:", (e.message || e.stack || e));
}
});
}
};

if (lkey === undefined || lkey === null) {
Expand Down

0 comments on commit e2fdf4f

Please sign in to comment.