[x ] Bug
Hello - tried to use
$pnp.storage.local.getOrPut(storageKeyName, xxx, expiration).then(
function (data) {
xxx
}
);
where expiration is custom data value. Unfortunately custom expiration date is never passed on to PnPClientStorageWrapper.prototype.put method so local storage entry is always sets with expire = util_1.Util.dateAdd(new Date(), "minute", this.defaultTimeoutMinutes); value.
PnPClientStorageWrapper.prototype.getOrPut = function (key, getter, expire) {
var _this = this;
if (!this.enabled) {
return getter();
}
if (!util_1.Util.isFunction(getter)) {
throw "Function expected for parameter 'getter'.";
}
return new Promise(function (resolve, reject) {
var o = _this.get(key);
if (o == null) {
getter().then(function (d) {
_this.put(key, d, expire);
resolve(d);
});
}
else {
resolve(o);
}
});
};
I was able to resolve this by updating _this.put(key, d); to _this.put(key, d, expire); as shown above.
Can pnp,js and pnp-min.js be updated so we can either use "defaultTimeoutMinutes" or pass custom expiration date to getOrPut method?
Thanks
[x ] Bug
Hello - tried to use
$pnp.storage.local.getOrPut(storageKeyName, xxx, expiration).then(
function (data) {
xxx
}
);
where expiration is custom data value. Unfortunately custom expiration date is never passed on to PnPClientStorageWrapper.prototype.put method so local storage entry is always sets with expire = util_1.Util.dateAdd(new Date(), "minute", this.defaultTimeoutMinutes); value.
PnPClientStorageWrapper.prototype.getOrPut = function (key, getter, expire) {
var _this = this;
if (!this.enabled) {
return getter();
}
if (!util_1.Util.isFunction(getter)) {
throw "Function expected for parameter 'getter'.";
}
return new Promise(function (resolve, reject) {
var o = _this.get(key);
if (o == null) {
getter().then(function (d) {
_this.put(key, d, expire);
resolve(d);
});
}
else {
resolve(o);
}
});
};
I was able to resolve this by updating _this.put(key, d); to _this.put(key, d, expire); as shown above.
Can pnp,js and pnp-min.js be updated so we can either use "defaultTimeoutMinutes" or pass custom expiration date to getOrPut method?
Thanks