Skip to content

Commit

Permalink
Merge pull request #32 from XbyOrange/v1.5.0
Browse files Browse the repository at this point in the history
V1.5.0
  • Loading branch information
javierbrea authored Oct 14, 2019
2 parents c1339ed + 247c189 commit 641d11a
Show file tree
Hide file tree
Showing 10 changed files with 2,157 additions and 1,693 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [TO BE DEPRECATED]
- 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.

## [1.5.0] - 2019-10-14
### Added
- Add `stats` property containing counters of method actions executions.

### Changed
- Upgrade devDependencies

## [1.4.0] - 2019-10-14
### Added
- Selectors can now return an array of sources.
Expand Down
8 changes: 8 additions & 0 deletions docs/selector/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,21 @@
* error - `<Error>` If read method returns an error, it will be accessible at this property.
* loading - `<Boolean>` Will be true while Selector read is in progress.
* value - `<Any>` Value returned by `read` method.
* stats - `<Object>` Object containing stats about method executions:
* dispatch - `<Number>` Counter of times that read method has been dispatched when there was no cache.
* success - `<Number>` Counter of times that read method has been resolved. No matter if result came from cache or not.
* error - `<Number>` Counter of times that read method has been rejected. No matter if result came from cache or not.
* Returns
* `<Any>` - Result of the parser function.
* create, update, delete `selector.create(data)` These methods can be used only when Selector returns another source.
* Statics:
* error - `<Error>` If read method returns an error, it will be accessible at this property.
* loading - `<Boolean>` Will be true while Selector read is in progress.
* value - `<Any>` Value returned by `read` method.
* stats - `<Object>` Object containing stats about method executions:
* dispatch - `<Number>` Counter of times that read method has been dispatched when there was no cache.
* success - `<Number>` Counter of times that read method has been resolved. No matter if result came from cache or not.
* error - `<Number>` Counter of times that read method has been rejected. No matter if result came from cache or not.
* Arguments
* data - `<Any>` Data that will be passed to the correspondant create, update or delete method of the returned source.
* Returns
Expand Down
25 changes: 24 additions & 1 deletion docs/selector/asynchronous-mutable-properties.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Asynchronous mutable properties

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

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

```

The `stats` property can be used to determine how many times a selector method has been dispatched, successfully read or errored.

It contains three counters corresponding to each method "action":

* `dispatch` - Increased each time the read method is dispatched and there is no cache.
* `success` - Increased each time the read method is called and it is resolved. No matter if result comes from cache or not.
* `error` - Increased each time the read method is called and it is rejected. No matter if result comes from cache or not.

```js
console.log(books.read.stats.dispatch) // 0
console.log(books.read.stats.error) // 0
console.log(books.read.stats.success) // 0

booksWithAuthors.read();

console.log(books.read.stats.dispatch) // 1

await booksWithAuthors.read()

console.log(books.read.stats.success) // 2

```
Loading

0 comments on commit 641d11a

Please sign in to comment.