Skip to content
This repository was archived by the owner on Oct 29, 2023. It is now read-only.

Commit 8e72532

Browse files
authored
Merge pull request #173 from data-provider/release
Release v2.9.1
2 parents be8f12e + a475bc1 commit 8e72532

File tree

6 files changed

+46
-8
lines changed

6 files changed

+46
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
### Fixed
1111
### Removed
1212

13+
## [2.9.1] - 2021-01-04
14+
15+
### Fixed
16+
- fix: Selector cleanDependenciesCache method was cleaning only in progress dependencies if the selector read was in progress, so previous dependencies were not being cleaned
17+
1318
## [2.9.0] - 2020-12-27
1419

1520
### Added

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@data-provider/core",
3-
"version": "2.9.0",
3+
"version": "2.9.1",
44
"description": "Async Data Provider agnostic about data origins",
55
"keywords": [
66
"data",

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
sonar.organization=data-provider
22
sonar.projectKey=data-provider-core
3-
sonar.projectVersion=2.9.0
3+
sonar.projectVersion=2.9.1
44

55
sonar.sources=src,test
66
sonar.exclusions=node_modules/**

src/Selector.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ class SelectorBase extends Provider {
230230
}
231231

232232
_unthrottledCleanDependenciesCache(options = {}) {
233-
if (this._inProgressDependencies.size > 0) {
234-
this._cleanCaches(Array.from(this._inProgressDependencies), options);
235-
} else {
236-
this._cleanCaches(this._resolvedDependencies, options);
237-
}
233+
const dependenciesToClean = new Set(this._resolvedDependencies);
234+
this._inProgressDependencies.forEach((dependency) => {
235+
dependenciesToClean.add(dependency);
236+
});
237+
this._cleanCaches(Array.from(dependenciesToClean), options);
238238
}
239239

240240
// Define base tag

test/selector/cache-dependencies-clean.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,39 @@ describe("Selector when cleanDependenciesCache method is called", () => {
113113
expect(dependency3.cleanDependenciesCache.callCount).toEqual(1);
114114
});
115115

116+
it("should call to clean all dependendencies cache, even when read is in progress", async () => {
117+
let readSelectorPromise;
118+
expect.assertions(3);
119+
sandbox.spy(dependency1, "cleanDependenciesCache");
120+
sandbox.spy(dependency2, "cleanDependenciesCache");
121+
sandbox.spy(dependency3, "cleanDependenciesCache");
122+
await selector.read();
123+
dependency3.cleanCache();
124+
readSelectorPromise = selector.read();
125+
selector.cleanDependenciesCache();
126+
await readSelectorPromise;
127+
expect(dependency1.cleanDependenciesCache.callCount).toEqual(1);
128+
expect(dependency2.cleanDependenciesCache.callCount).toEqual(1);
129+
expect(dependency3.cleanDependenciesCache.callCount).toEqual(1);
130+
});
131+
132+
it("should return last data returned by all dependencies, even when read is in progress", async () => {
133+
let readSelectorPromise;
134+
expect.assertions(2);
135+
results = {
136+
dependency1: ["foo", "foo2"],
137+
dependency2: ["foo3", "foo4"],
138+
dependency3: ["foo5", "foo6"],
139+
};
140+
const result = await selector.read();
141+
expect(result).toEqual(["foo", "foo3", "foo5"]);
142+
dependency3.cleanCache();
143+
readSelectorPromise = selector.read();
144+
selector.cleanDependenciesCache();
145+
await readSelectorPromise;
146+
expect(selector.state.data).toEqual(["foo2", "foo4", "foo6"]);
147+
});
148+
116149
it("should call to clean all dependendencies cache except that in the except option", async () => {
117150
expect.assertions(3);
118151
sandbox.spy(dependency1, "cleanDependenciesCache");

0 commit comments

Comments
 (0)