shared-store
Advanced tools
Comparing version 1.0.9 to 1.0.10
@@ -0,1 +1,5 @@ | ||
1.0.10 | ||
------ | ||
* fix ENOTFOUND error by intercepting init rejection - @chkhoo #18 | ||
1.0.9 | ||
@@ -2,0 +6,0 @@ ----- |
@@ -156,3 +156,3 @@ // Generated by CoffeeScript 1.9.0 | ||
activeLoader = function(meta, loader, tmpDir) { | ||
var cachedData, data, fromCache, onDataLoaded, rawData, tearDownCrashHandler, _ref1; | ||
var data, fromCache, onDataLoaded, rawData, tearDownCrashHandler, _ref1; | ||
rawData = meta.flatMapLatest(loader).map(function(data) { | ||
@@ -163,18 +163,9 @@ data.usingCache = false; | ||
_ref1 = crashRecovery(tmpDir), onDataLoaded = _ref1.onDataLoaded, tearDownCrashHandler = _ref1.tearDownCrashHandler; | ||
data = rawData.tap(onDataLoaded, tearDownCrashHandler, tearDownCrashHandler).publish(); | ||
data = rawData.tap(onDataLoaded, tearDownCrashHandler, tearDownCrashHandler); | ||
fromCache = tryCache(tmpDir); | ||
cachedData = fromCache.takeUntil(data).merge(data).distinctUntilChanged(property('data'), isEqual).flatMapLatest(partial(writeCache, tmpDir)).publish(); | ||
cachedData.connectAll = function() { | ||
data.connect(); | ||
return cachedData.connect(); | ||
}; | ||
return cachedData; | ||
return fromCache.takeUntil(data).merge(data).distinctUntilChanged(property('data'), isEqual).flatMapLatest(partial(writeCache, tmpDir)).publish(); | ||
}; | ||
passiveLoader = function(tmpDir) { | ||
var data, rawData; | ||
rawData = latestCacheFile(tmpDir, true); | ||
data = rawData.publish(); | ||
data.connectAll = data.connect; | ||
return data; | ||
return latestCacheFile(tmpDir, true).publish(); | ||
}; | ||
@@ -184,7 +175,9 @@ | ||
debug('cachedLoader(%j)', active); | ||
if (active) { | ||
return activeLoader(meta, loader, tmpDir); | ||
} else { | ||
return passiveLoader(tmpDir); | ||
} | ||
loader = active ? activeLoader(meta, loader, tmpDir) : passiveLoader(tmpDir); | ||
return Observable.create(function(observer) { | ||
loader.subscribe(observer); | ||
loader.connect(); | ||
}); | ||
}; | ||
this.latestCacheFile = latestCacheFile; |
@@ -35,3 +35,3 @@ // Generated by CoffeeScript 1.9.0 | ||
'use strict'; | ||
var EventEmitter, Observable, Promise, RETRY_MULTIPLIER, SharedStore, TEN_MINUTES, TEN_SECONDS, cachedLoader, cluster, freeze, path, property, safeMerge, | ||
var EventEmitter, Observable, Promise, RETRY_MULTIPLIER, SharedStore, TEN_MINUTES, TEN_SECONDS, cachedLoader, cluster, freeze, latestCacheFile, path, property, safeMerge, _ref, | ||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, | ||
@@ -55,3 +55,3 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
cachedLoader = require('./cache').cachedLoader; | ||
_ref = require('./cache'), cachedLoader = _ref.cachedLoader, latestCacheFile = _ref.latestCacheFile; | ||
@@ -80,13 +80,12 @@ safeMerge = require('./safe-merge'); | ||
} | ||
temp = path.resolve(temp); | ||
this._temp = path.resolve(temp); | ||
this._createStream = (function(_this) { | ||
return function() { | ||
var meta, _ref; | ||
if ((_ref = _this.subscription) != null) { | ||
_ref.dispose(); | ||
var meta, _ref1; | ||
if ((_ref1 = _this.subscription) != null) { | ||
_ref1.dispose(); | ||
} | ||
meta = _this._createMeta(); | ||
_this.stream = cachedLoader(meta, loader, temp, active); | ||
_this.subscription = _this.stream.subscribe(_this._handleUpdate, _this._handleError); | ||
return _this.stream.connectAll(); | ||
_this.stream = cachedLoader(meta, loader, _this._temp, active); | ||
return _this.subscription = _this.stream.subscribe(_this._handleUpdate, _this._handleError); | ||
}; | ||
@@ -101,4 +100,4 @@ })(this); | ||
SharedStore.prototype.getCurrent = function() { | ||
var _ref; | ||
return (_ref = this._cache) != null ? _ref.data : void 0; | ||
var _ref1; | ||
return (_ref1 = this._cache) != null ? _ref1.data : void 0; | ||
}; | ||
@@ -118,3 +117,3 @@ | ||
return function(resolve, reject) { | ||
var current; | ||
var current, originalErr; | ||
current = _this.getCurrent(); | ||
@@ -124,3 +123,8 @@ if (current != null) { | ||
} | ||
return _this.stream.take(1).map(property('data')).subscribe(resolve, reject); | ||
originalErr = null; | ||
return _this.stream.take(1).map(property('data')).tapOnError(function(err) { | ||
return originalErr = err; | ||
})["catch"](latestCacheFile(_this._temp)).subscribe(resolve, function(err) { | ||
return reject(originalErr); | ||
}); | ||
}; | ||
@@ -150,3 +154,3 @@ })(this)); | ||
SharedStore.prototype._handleUpdate = function(_arg) { | ||
var data, source, time, usingCache, _ref; | ||
var data, source, time, usingCache, _ref1; | ||
data = _arg.data, time = _arg.time, source = _arg.source, usingCache = _arg.usingCache; | ||
@@ -163,3 +167,3 @@ if (usingCache === false) { | ||
isWorker: cluster.isWorker, | ||
id: (_ref = cluster.worker) != null ? _ref.id : void 0 | ||
id: (_ref1 = cluster.worker) != null ? _ref1.id : void 0 | ||
}); | ||
@@ -170,5 +174,5 @@ return this.emit('data', this._cache.data); | ||
SharedStore.prototype._handleMetaUpdate = function(_at__options) { | ||
var _ref; | ||
var _ref1; | ||
this._options = _at__options; | ||
return (_ref = this._metaObserver) != null ? _ref.onNext(this._options) : void 0; | ||
return (_ref1 = this._metaObserver) != null ? _ref1.onNext(this._options) : void 0; | ||
}; | ||
@@ -175,0 +179,0 @@ |
{ | ||
"name": "shared-store", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "Keeping config data in sync", | ||
@@ -5,0 +5,0 @@ "main": "lib/shared-store.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97124
1102