This commit is contained in:
William Bartholomew 2016-12-22 10:02:46 -08:00
Родитель 8e39858016
Коммит aa93a355aa
2 изменённых файлов: 11 добавлений и 9 удалений

Просмотреть файл

@ -81,10 +81,10 @@ class RefreshingConfig extends EventEmitter {
if (!extension) {
return this;
}
if (typeof (extension['subscribe']) === 'function' || typeof (extension['shouldRefresh']) === 'function') {
if (typeof (extension['subscribe']) === 'function') {
extension.subscribe(this);
}
if (typeof (extension['subscribe']) === 'function') {
extension.subscribe(this);
}
if (typeof (extension['shouldRefresh']) === 'function') {
this.refreshPolicies.push(extension);
}
if (typeof (extension['publish']) === 'function') {
@ -121,11 +121,9 @@ class RefreshingConfig extends EventEmitter {
if (!shouldRefresh) {
for (let i = 0; i < this.refreshPolicies.length; i++) {
const refreshPolicy = this.refreshPolicies[i];
if (typeof (refreshPolicy['shouldRefresh']) === 'function') {
if (refreshPolicy.shouldRefresh()) {
shouldRefresh = true;
break;
}
if (refreshPolicy.shouldRefresh()) {
shouldRefresh = true;
break;
}
}
}

Просмотреть файл

@ -291,4 +291,8 @@ describe('IntervalRefreshPolicy', () => {
target.subscribe({});
}).should.throw(Error, /already subscribed/i);
});
it('does not throw if you unsubscribe when not subscribed', () => {
const target = new config.RefreshPolicy.IntervalRefreshPolicy(1000);
target.unsubscribe();
});
});