Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
toomuchdesign committed Jan 30, 2019
1 parent 1338644 commit af8daec
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 96 deletions.
91 changes: 52 additions & 39 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
# Change log

## 3.0.0

### Breaking Changes

* Update TypeScript typings
* Introduce typings for heterogeneous selectors
* Introduce typings for any number of uniform selectors

### New Features

* Update TypeScript typings
* Introduce typings for `dependencies` property

## 2.3.0

### New Features

- Do not include test files on publish
- Introduce new selectors' methods/properties:
- `dependencies` property
- `recomputations` method
- `resetRecomputations` method
* Do not include test files on publish
* Introduce new selectors' methods/properties:
* `dependencies` property
* `recomputations` method
* `resetRecomputations` method

## 2.2.0

- Fix cache object's `isValidCacheKey` method TS type definition
* Fix cache object's `isValidCacheKey` method TS type definition

### New Features

- Upgrade to babel 7
- Update dev dependencies
* Upgrade to babel 7
* Update dev dependencies

### Breaking Changes (not considered worth a major release)

Expand All @@ -27,83 +40,83 @@

### New Features

- Expose `cache` property
* Expose `cache` property

## 2.0.0

### Breaking Changes

- `cacheKey` values no more restricted by default to `number` or `string`
- `cacheKey` validation delegated to `cacheObject`'s `isValidCacheKey` method
- `selectorCreator` argument removed in favour of `options` object
- `console.warn` when `resolverFunction` returns invalid `cacheKey`
- `cacheObject` export names renamed _(old ones are deprecated)_:
- `FlatCacheObject` -> `FlatObjectCache`
- `FifoCacheObject` -> `FifoObjectCache`
- `LruCacheObject` -> `LruObjectCache`
* `cacheKey` values no more restricted by default to `number` or `string`
* `cacheKey` validation delegated to `cacheObject`'s `isValidCacheKey` method
* `selectorCreator` argument removed in favour of `options` object
* `console.warn` when `resolverFunction` returns invalid `cacheKey`
* `cacheObject` export names renamed _(old ones are deprecated)_:
* `FlatCacheObject` -> `FlatObjectCache`
* `FifoCacheObject` -> `FifoObjectCache`
* `LruCacheObject` -> `LruObjectCache`

### New Features

- Added 3 new `cacheObject` implementations using `ES Map` objects accepting any value as `cacheKey`:
- `FlatMapCache`
- `FifoMapCache`
- `LruMapCache`
- Add a `sideEffects: false` flag for Webpack 4
* Added 3 new `cacheObject` implementations using `ES Map` objects accepting any value as `cacheKey`:
* `FlatMapCache`
* `FifoMapCache`
* `LruMapCache`
* Add a `sideEffects: false` flag for Webpack 4

## 1.0.1

- Remove wrong line at the beginning of the docs
* Remove wrong line at the beginning of the docs

## 1.0.0

### Breaking Changes

- `selectorCreator` argument is deprecated in favour of an option object
* `selectorCreator` argument is deprecated in favour of an option object

### New Features

- Accept an option object to provide `cacheObject` and `selectorCreator` options
- Extract caching logic into pluggable/customizable cache objects
- Introduce `Rollup.js` as bundler
- Make compilation cross-platform
* Accept an option object to provide `cacheObject` and `selectorCreator` options
* Extract caching logic into pluggable/customizable cache objects
* Introduce `Rollup.js` as bundler
* Make compilation cross-platform

## 0.6.3

- Add TS type definition for optional `selectorCreator`
* Add TS type definition for optional `selectorCreator`

## 0.6.2

- Fix wrong UMD reselect global import
* Fix wrong UMD reselect global import

## 0.6.1

- Fix TypeScript `OutputCachedSelector` and `OutputParametricCachedSelector` type definitions
* Fix TypeScript `OutputCachedSelector` and `OutputParametricCachedSelector` type definitions

## 0.6.0

- Add TypeScript type definitions
* Add TypeScript type definitions

## 0.5.0

- Expose `resultFunc` attribute
* Expose `resultFunc` attribute

## 0.4.0

- Expose `removeMatchingSelector` method
- Expose `clearCache` method
* Expose `removeMatchingSelector` method
* Expose `clearCache` method

## 0.3.0

- Add UMD dist
* Add UMD dist

## 0.2.0

- Expose `getMatchingSelector` method to retrieve the instance of cached selectors
* Expose `getMatchingSelector` method to retrieve the instance of cached selectors

## 0.1.0

- Allow resolver function to return keys of type number
* Allow resolver function to return keys of type number

## 0.0.0

- Initial release
* Initial release
112 changes: 55 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

Useful to:

- **retain selector's cache** when sequentially **called with one/few different arguments** ([example][example-1])
- **join similar selectors** into one
- **share selectors** with props across multiple component instances (see [reselect example][reselect-sharing-selectors] and [re-reselect solution][example-2])
- **instantiate** selectors **on runtime**
* **retain selector's cache** when sequentially **called with one/few different arguments** ([example][example-1])
* **join similar selectors** into one
* **share selectors** with props across multiple component instances (see [reselect example][reselect-sharing-selectors] and [re-reselect solution][example-2])
* **instantiate** selectors **on runtime**

<!-- prettier-ignore -->
```js
Expand Down Expand Up @@ -57,41 +57,41 @@ const fooResultAgain = cachedSelector(state, 'foo');

## Table of contents

- [Re-reselect](#re-reselect)
- [Table of contents](#table-of-contents)
- [Installation](#installation)
- [Why? + example](#why--example)
- [Re-reselect solution](#re-reselect-solution)
- [Other viable solutions](#other-viable-solutions)
- [1- Declare a different selector for each different call](#1--declare-a-different-selector-for-each-different-call)
- [2- Declare a `makeGetPieceOfData` selector factory as explained in Reselect docs](#2--declare-a-makegetpieceofdata-selector-factory-as-explained-in-reselect-docs)
- [3- Wrap your `makeGetPieceOfData` selector factory into a memoizer function and call the returning memoized selector](#3--wrap-your-makegetpieceofdata-selector-factory-into-a-memoizer-function-and-call-the-returning-memoized-selector)
- [Examples](#examples)
- [FAQ](#faq)
- [How do I wrap my existing selector with re-reselect?](#how-do-i-wrap-my-existing-selector-with-re-reselect)
- [How do I use multiple inputs to set the cacheKey?](#how-do-i-use-multiple-inputs-to-set-the-cachekey)
- [How do I limit the cache size?](#how-do-i-limit-the-cache-size)
- [How to share a selector across multiple components while passing in props and retaining memoization?](#how-to-share-a-selector-across-multiple-components-while-passing-in-props-and-retaining-memoization)
- [How do I test a re-reselect selector?](#how-do-i-test-a-re-reselect-selector)
- [Testing `reselect` selectors stored in the cache](#testing-reselect-selectors-stored-in-the-cache)
- [API](#api)
- [reReselect([reselect's createSelector arguments])(resolverFunction, { cacheObject, selectorCreator })](#rereselectreselects-createselector-argumentsresolverfunction--cacheobject-selectorcreator)
- [resolverFunction](#resolverfunction)
- [options.cacheObject](#optionscacheobject)
- [Custom cache strategy object](#custom-cache-strategy-object)
- [options.selectorCreator](#optionsselectorcreator)
- [Returns](#returns)
- [reReselectInstance(selectorArguments)](#rereselectinstanceselectorarguments)
- [reReselectInstance`.getMatchingSelector(selectorArguments)`](#rereselectinstancegetmatchingselectorselectorarguments)
- [reReselectInstance`.removeMatchingSelector(selectorArguments)`](#rereselectinstanceremovematchingselectorselectorarguments)
- [reReselectInstance`.cache`](#rereselectinstancecache)
- [reReselectInstance`.clearCache()`](#rereselectinstanceclearcache)
- [reReselectInstance`.dependencies`](#rereselectinstancedependencies)
- [reReselectInstance`.resultFunc`](#rereselectinstanceresultfunc)
- [reReselectInstance`.recomputations()`](#rereselectinstancerecomputations)
- [reReselectInstance`.resetRecomputations()`](#rereselectinstanceresetrecomputations)
- [Todo's](#todos)
- [Contributors](#contributors)
* [Re-reselect](#re-reselect)
* [Table of contents](#table-of-contents)
* [Installation](#installation)
* [Why? + example](#why--example)
* [Re-reselect solution](#re-reselect-solution)
* [Other viable solutions](#other-viable-solutions)
* [1- Declare a different selector for each different call](#1--declare-a-different-selector-for-each-different-call)
* [2- Declare a `makeGetPieceOfData` selector factory as explained in Reselect docs](#2--declare-a-makegetpieceofdata-selector-factory-as-explained-in-reselect-docs)
* [3- Wrap your `makeGetPieceOfData` selector factory into a memoizer function and call the returning memoized selector](#3--wrap-your-makegetpieceofdata-selector-factory-into-a-memoizer-function-and-call-the-returning-memoized-selector)
* [Examples](#examples)
* [FAQ](#faq)
* [How do I wrap my existing selector with re-reselect?](#how-do-i-wrap-my-existing-selector-with-re-reselect)
* [How do I use multiple inputs to set the cacheKey?](#how-do-i-use-multiple-inputs-to-set-the-cachekey)
* [How do I limit the cache size?](#how-do-i-limit-the-cache-size)
* [How to share a selector across multiple components while passing in props and retaining memoization?](#how-to-share-a-selector-across-multiple-components-while-passing-in-props-and-retaining-memoization)
* [How do I test a re-reselect selector?](#how-do-i-test-a-re-reselect-selector)
* [Testing `reselect` selectors stored in the cache](#testing-reselect-selectors-stored-in-the-cache)
* [API](#api)
* [reReselect([reselect's createSelector arguments])(resolverFunction, { cacheObject, selectorCreator })](#rereselectreselects-createselector-argumentsresolverfunction--cacheobject-selectorcreator)
* [resolverFunction](#resolverfunction)
* [options.cacheObject](#optionscacheobject)
* [Custom cache strategy object](#custom-cache-strategy-object)
* [options.selectorCreator](#optionsselectorcreator)
* [Returns](#returns)
* [reReselectInstance(selectorArguments)](#rereselectinstanceselectorarguments)
* [reReselectInstance`.getMatchingSelector(selectorArguments)`](#rereselectinstancegetmatchingselectorselectorarguments)
* [reReselectInstance`.removeMatchingSelector(selectorArguments)`](#rereselectinstanceremovematchingselectorselectorarguments)
* [reReselectInstance`.cache`](#rereselectinstancecache)
* [reReselectInstance`.clearCache()`](#rereselectinstanceclearcache)
* [reReselectInstance`.dependencies`](#rereselectinstancedependencies)
* [reReselectInstance`.resultFunc`](#rereselectinstanceresultfunc)
* [reReselectInstance`.recomputations()`](#rereselectinstancerecomputations)
* [reReselectInstance`.resetRecomputations()`](#rereselectinstanceresetrecomputations)
* [Todo's](#todos)
* [Contributors](#contributors)

## Installation

Expand Down Expand Up @@ -126,8 +126,8 @@ What happens, here? `getPieceOfData` **selector cache is invalidated** on each c

`resolverFunction` is a **custom function** which:

- takes the same arguments as the final selector (in the example: `state`, `itemId`, `'dataX'`)
- returns a `cacheKey`.
* takes the same arguments as the final selector (in the example: `state`, `itemId`, `'dataX'`)
* returns a `cacheKey`.

Note that the **same `reselect` selector instance** stored in cache will be used for computing data for the **same `cacheKey`** (1:1).

Expand Down Expand Up @@ -166,19 +166,19 @@ Easy, but doesn't scale. See ["join similar selectors" example][example-1].

The solution suggested in [Reselect docs][reselect-sharing-selectors] is fine, but it has a few downsides:

- Bloats your code by exposing both `get` selectors and `makeGet` selector factories
- Needs to import/call selector factory instead of directly using selector
- Two different instances given the same arguments, will individually store and recompute the same result (read [this](https://github.com/reactjs/reselect/pull/213))
* Bloats your code by exposing both `get` selectors and `makeGet` selector factories
* Needs to import/call selector factory instead of directly using selector
* Two different instances given the same arguments, will individually store and recompute the same result (read [this](https://github.com/reactjs/reselect/pull/213))

#### 3- Wrap your `makeGetPieceOfData` selector factory into a memoizer function and call the returning memoized selector

This is what `re-reselect` actually does! :-) It's quite verbose (since has to be repeated for each selector), **that's why re-reselect is here**.

## Examples

- [Join similar selectors][example-1]
- [Avoid selector factories][example-2]
- [Cache API calls][example-3]
* [Join similar selectors][example-1]
* [Avoid selector factories][example-2]
* [Cache API calls][example-3]

## FAQ

Expand Down Expand Up @@ -268,10 +268,10 @@ Just like a normal reselect selector!

`re-reselect` selectors expose the same `reselect` testing methods:

- `dependencies`
- `resultFunc`
- `recomputations`
- `resetRecomputations`
* `dependencies`
* `resultFunc`
* `recomputations`
* `resetRecomputations`

Read more about testing selectors on [`reselect` docs][reselect-test-selectors].

Expand Down Expand Up @@ -323,8 +323,8 @@ import createCachedSelector from 're-reselect';

**Re-reselect** accepts reselect's original [`createSelector` arguments][reselect-create-selector] and returns a new function which accepts **2 arguments**:

- `resolverFunction`
- `options { cacheObject, selectorCreator }` _(optional)_
* `resolverFunction`
* `options { cacheObject, selectorCreator }` _(optional)_

#### resolverFunction

Expand Down Expand Up @@ -433,10 +433,8 @@ Reset `recomputations` count.

## Todo's

- Introduce typings for heterogeneous selectors. See [this](https://github.com/reduxjs/reselect/pull/274) and [this](https://github.com/toomuchdesign/re-reselect/pull/63).
- Consider introducing typings for `selector.dependencies` method
- Improve TS tests readability
- More examples
* Improve TS tests readability
* More examples

## Contributors

Expand Down

0 comments on commit af8daec

Please sign in to comment.