Skip to content

Commit 641d11a

Browse files
authored
Merge pull request #32 from XbyOrange/v1.5.0
V1.5.0
2 parents c1339ed + 247c189 commit 641d11a

10 files changed

+2157
-1693
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
## [TO BE DEPRECATED]
1515
- Last argument of Selectors will stop being assigned as "defaultValue". To define default value, it will be mandatory to pass an options object as last argument, containing a "defaultValue" property.
1616

17+
## [1.5.0] - 2019-10-14
18+
### Added
19+
- Add `stats` property containing counters of method actions executions.
20+
21+
### Changed
22+
- Upgrade devDependencies
23+
1724
## [1.4.0] - 2019-10-14
1825
### Added
1926
- Selectors can now return an array of sources.

docs/selector/api.md

+8
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,21 @@
4343
* error - `<Error>` If read method returns an error, it will be accessible at this property.
4444
* loading - `<Boolean>` Will be true while Selector read is in progress.
4545
* value - `<Any>` Value returned by `read` method.
46+
* stats - `<Object>` Object containing stats about method executions:
47+
* dispatch - `<Number>` Counter of times that read method has been dispatched when there was no cache.
48+
* success - `<Number>` Counter of times that read method has been resolved. No matter if result came from cache or not.
49+
* error - `<Number>` Counter of times that read method has been rejected. No matter if result came from cache or not.
4650
* Returns
4751
* `<Any>` - Result of the parser function.
4852
* create, update, delete `selector.create(data)` These methods can be used only when Selector returns another source.
4953
* Statics:
5054
* error - `<Error>` If read method returns an error, it will be accessible at this property.
5155
* loading - `<Boolean>` Will be true while Selector read is in progress.
5256
* value - `<Any>` Value returned by `read` method.
57+
* stats - `<Object>` Object containing stats about method executions:
58+
* dispatch - `<Number>` Counter of times that read method has been dispatched when there was no cache.
59+
* success - `<Number>` Counter of times that read method has been resolved. No matter if result came from cache or not.
60+
* error - `<Number>` Counter of times that read method has been rejected. No matter if result came from cache or not.
5361
* Arguments
5462
* data - `<Any>` Data that will be passed to the correspondant create, update or delete method of the returned source.
5563
* Returns

docs/selector/asynchronous-mutable-properties.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Asynchronous mutable properties
22

3-
Selectors methods have three properties that change value depending of the current status: `loading`, `error`, `value`
3+
Selectors methods have four properties that change value depending of the current status: `loading`, `error`, `value` and `stats`
44

55
```js
66
console.log(books.read.value) // undefined
@@ -15,3 +15,26 @@ console.log(books.read.loading) // false
1515
console.log(books.read.value) // value returned by parser function.
1616

1717
```
18+
19+
The `stats` property can be used to determine how many times a selector method has been dispatched, successfully read or errored.
20+
21+
It contains three counters corresponding to each method "action":
22+
23+
* `dispatch` - Increased each time the read method is dispatched and there is no cache.
24+
* `success` - Increased each time the read method is called and it is resolved. No matter if result comes from cache or not.
25+
* `error` - Increased each time the read method is called and it is rejected. No matter if result comes from cache or not.
26+
27+
```js
28+
console.log(books.read.stats.dispatch) // 0
29+
console.log(books.read.stats.error) // 0
30+
console.log(books.read.stats.success) // 0
31+
32+
booksWithAuthors.read();
33+
34+
console.log(books.read.stats.dispatch) // 1
35+
36+
await booksWithAuthors.read()
37+
38+
console.log(books.read.stats.success) // 2
39+
40+
```

0 commit comments

Comments
 (0)