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

Commit be8f12e

Browse files
authored
Merge pull request #171 from data-provider/release
Release v2.9.0
2 parents ed246c6 + 47419f1 commit be8f12e

File tree

12 files changed

+311
-18
lines changed

12 files changed

+311
-18
lines changed

CHANGELOG.md

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

13+
## [2.9.0] - 2020-12-27
14+
15+
### Added
16+
- feat: Allow defining baseTags property in addons. Will be extended with "tags" option when instantiated for calculating provider tags. (#143)
17+
- feat: Add tags getter
18+
- feat: Add "selector" base tag to selectors (#163)
19+
- feat: Add `cleanDependenciesCache` method to `providers` handler (#164)
20+
21+
### Fixed
22+
- docs(readme): Fix typos
23+
1324
## [2.8.2] - 2020-12-12
1425
### Added
1526
- chore(ci): Migrate from Travis CI to github actions

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
# [![Data Provider][logo]][home]
88

9-
> Async Data Provider. Powered by Redux. Agnostic about data origins. Framework agnostic.
9+
> Async Data Provider. Powered by Redux. Agnostic about data origins. Agnostic about UI Frameworks.
1010
11-
Data Provider is a data provider _(surprise!)_ with states ands built-in cache for JavaScript apps.
11+
Data Provider is a data provider _(surprise!)_ with states and built-in cache for JavaScript apps.
1212

1313
The main target of the library are front-end applications, but it could be used also in [Node.js][nodejs].
1414

@@ -19,7 +19,7 @@ As its states are managed with [Redux][redux], you can take advantage of his lar
1919

2020
You can use Data Provider with [React][react], or with any other view library. [Separated addons][addons] are available for that purpose, as [@data-provider/react][data-provider-react].
2121

22-
Data Provider is __agnostic about data origins__, so it can be used to read data from a REST API, from localStorage, or from any other origin. Choose one of the [available addons][addons] depending of the type of the origin you want to read from, as [@data-provider/axios][data-provider-axios], or [@data-provider/browser-storage][data-provider-browser-storage].
22+
Data Provider is __agnostic about data origins__, so it can be used to read data from a REST API, from `localStorage`, or from any other origin. Choose one of the [available addons][addons] depending of the type of the origin you want to read from, as [`@data-provider/axios`][data-provider-axios], or [`@data-provider/browser-storage`][data-provider-browser-storage].
2323

2424
It has a __light weight__, 4.2KB gzipped in UMD format _(you have to add the Redux weight to this)_, and addons usually are even lighter.
2525

@@ -40,7 +40,7 @@ We have a website available to help you to learn to use Data Provider. There are
4040

4141
### Agnostic about data origins
4242

43-
The Provider class provides the cache, state handler, etc., but not the "read" method. The "read" behavior is implemented by __different [Data Provider Origins addons][addons]__.
43+
The Provider class provides the cache, state handler, etc., but not the `read` method. The `read` behavior is implemented by __different [Data Provider Origins addons][addons]__.
4444

4545
There are different origins addons available, such as __[Axios][data-provider-axios], [LocalStorage][data-provider-browser-storage], [Memory][data-provider-memory], etc.__ and building your own is so easy as extending the Provider class with a custom "readMethod".
4646

@@ -116,11 +116,11 @@ export default RenderBooksTwice;
116116

117117
### Queryable
118118

119-
Providers and selectors instances can be queried, which returns a new child instance with his own "query value".
119+
Providers and selectors instances can be queried, which returns a new child instance with its own `query value`.
120120

121121
Each different child has a different cache, different state, etc.
122122

123-
Different origins can use the "query" value for different purposes (API origins will normally use it for adding different params or query strings to the provider url, for example)
123+
Different origins can use the `queryValue` for different purposes (API origins will normally use it for adding different params or query strings to the provider url, for example)
124124

125125
When the parent provider cache is clean, also the children is. _(For example, cleaning the cache of an API origin requesting to "/api/books", will also clean the cache for "/api/books?author=2")_
126126

@@ -148,11 +148,11 @@ export default Book;
148148

149149
Data Provider is not concerned about the views, but UI binding addons are available.
150150

151-
For example, the [@data-provider/react][data-provider-react] package __gives you hooks to easily retrieve and provide data and other data-provider states to your components__,
151+
For example, the [@data-provider/react][data-provider-react] package __gives you hooks to easily retrieve and provide data__ and other data-provider states to React components.
152152

153-
It also provides __HOCs like "withData", "withLoading", etc., creating a wrapper component handling all the logic for you.__
153+
It also provides __HOCs__ like "withData", "withLoading", etc. creating a wrapper component handling all the logic for you.
154154

155-
__Optimized__, it takes care of reading the data and re-renders the component only when the provider desired props have changed. It also takes care of reading the data again every time the cache of the provider is invalidated.
155+
__Optimized__, it takes care of reading the data and re-renders the component only when the provider desired properties have changed. It also takes care of reading the data again every time the cache of the provider is invalidated.
156156

157157
```jsx
158158
import { useData, useLoading, useError } from "@data-provider/react";

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = {
2626

2727
// The glob patterns Jest uses to detect test files
2828
testMatch: ["<rootDir>/test/**/*.js"],
29-
// testMatch: ["<rootDir>/test/provider/clean-cache-throttle.js"],
29+
// testMatch: ["<rootDir>/test/providers/config.js"],
3030

3131
// The test environment that will be used for testing
3232
testEnvironment: "node",

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "@data-provider/core",
3-
"version": "2.8.2",
3+
"version": "2.9.0",
44
"description": "Async Data Provider agnostic about data origins",
55
"keywords": [
66
"data",
77
"provider",
8+
"async",
89
"redux",
910
"selector",
1011
"cache",

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.8.2
3+
sonar.projectVersion=2.9.0
44

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

src/Provider.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import { storeManager } from "./storeManager";
1313
import {
1414
childId,
1515
eventNamespace,
16-
removeFalsy,
17-
ensureArray,
16+
arrayWithoutFalsies,
1817
isFunction,
1918
isUndefined,
2019
ANY,
@@ -34,7 +33,10 @@ class Provider {
3433
this._emitChild = this._emitChild.bind(this);
3534
this._options = { ...defaultOptions, ...options };
3635
this._query = { ...query };
37-
this._tags = removeFalsy(ensureArray(this._options.tags));
36+
this._tags = [
37+
...arrayWithoutFalsies(this.baseTags),
38+
...arrayWithoutFalsies(this._options.tags),
39+
];
3840
this._children = new Map();
3941
this._queryMethods = new Map();
4042
this._queryMethodsParsers = new Map();
@@ -246,6 +248,10 @@ class Provider {
246248
return this._options;
247249
}
248250

251+
get tags() {
252+
return this._tags;
253+
}
254+
249255
// Methods to be used for testing
250256

251257
get queryMethods() {

src/Selector.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ http://www.apache.org/licenses/LICENSE-2.0
99
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
1010
*/
1111

12-
import { CLEAN_CACHE, isFunction, isArray, isPromise, ensureArray } from "./helpers";
12+
import {
13+
SELECTORS_TAG,
14+
CLEAN_CACHE,
15+
isFunction,
16+
isArray,
17+
isPromise,
18+
ensureArray,
19+
} from "./helpers";
1320
import Provider from "./Provider";
1421
import CatchDependency from "./CatchDependency";
1522

@@ -230,6 +237,12 @@ class SelectorBase extends Provider {
230237
}
231238
}
232239

240+
// Define base tag
241+
242+
get baseTags() {
243+
return SELECTORS_TAG;
244+
}
245+
233246
// Methods to be used for testing
234247

235248
get dependencies() {

src/helpers.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const defaultOptions = {
2424
cleanCacheThrottle: 0,
2525
};
2626

27+
export const SELECTORS_TAG = "selector";
2728
export const INIT = "init";
2829
export const CLEAN_CACHE = "cleanCache";
2930
export const RESET_STATE = "resetState";
@@ -88,6 +89,10 @@ export function removeFalsy(array) {
8889
return array.filter((el) => !!el);
8990
}
9091

92+
export function arrayWithoutFalsies(els) {
93+
return removeFalsy(ensureArray(els));
94+
}
95+
9196
export function message(text) {
9297
return `@data-provider/core: ${text}`;
9398
}

src/providers.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ export class ProvidersHandler {
5555
return this._run("cleanCache", options);
5656
}
5757

58+
cleanDependenciesCache(options) {
59+
return this._run("cleanDependenciesCache", options);
60+
}
61+
5862
resetState() {
5963
return this._run("resetState");
6064
}
@@ -174,6 +178,10 @@ export class Providers {
174178
return this._allProviders.cleanCache(options);
175179
}
176180

181+
cleanDependenciesCache(options) {
182+
return this._allProviders.cleanDependenciesCache(options);
183+
}
184+
177185
resetState() {
178186
return this._allProviders.resetState();
179187
}

0 commit comments

Comments
 (0)