Skip to content

Commit

Permalink
Fixes docs for cached
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelbr committed Mar 5, 2015
1 parent c9b2173 commit f7d4afd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 39 deletions.
32 changes: 9 additions & 23 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ Directly fetch `cache` to use outside of Omniscient.
You can do this if you want to define functions that caches computed
result to avoid recomputing if invoked with equal arguments as last time.
Returns optimized version of given `f` function for repeated
calls with an equal inputs. Returned function caches last input
and a result of the computation for it, which is handy for
optimizing `render` when computations are run on unchanged parts
of state. Although note that only last result is cached so it is
not practical to call it mulitple times with in the same `render`
call.
### Parameters
Expand All @@ -355,7 +363,7 @@ result to avoid recomputing if invoked with equal arguments as last time.
**Returns** `Function`,
**Returns** `Function`, Optimized function
### `cached.withDefaults([Options])`
Expand All @@ -380,28 +388,6 @@ Create a “local” instance of the `cache` with overriden defaults.
**Returns** `Function`, cached with overriden defaults
### `shouldComponentUpdate.isEqualState(function)`

Returns optimized version of given `f` function for repeated
calls with an equal inputs. Returned function caches last input
and a result of the computation for it, which is handy for
optimizing `render` when computations are run on unchanged parts
of state. Although note that only last result is cached so it is
not practical to call it mulitple times with in the same `render`
call.


### Parameters

| param | type | description |
| ---------- | -------- | ------------------ |
| `function` | Function | doing computation |



**Returns** `Function`, Optimized function.

## Private members
Expand Down
25 changes: 9 additions & 16 deletions cached.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ var shouldupdate = require('./shouldupdate');
* You can do this if you want to define functions that caches computed
* result to avoid recomputing if invoked with equal arguments as last time.
*
* Returns optimized version of given `f` function for repeated
* calls with an equal inputs. Returned function caches last input
* and a result of the computation for it, which is handy for
* optimizing `render` when computations are run on unchanged parts
* of state. Although note that only last result is cached so it is
* not practical to call it mulitple times with in the same `render`
* call.
*
* @param {Function} Function that does a computation.
*
* @module cached
* @returns {Function}
* @returns {Function} Optimized function
* @api public
*/
module.exports = factory();
Expand All @@ -36,21 +44,6 @@ module.exports.withDefaults = factory;
function factory (methods) {
var isEqual = (methods && methods.isEqualProps) || shouldupdate.isEqualProps;

/**
* Returns optimized version of given `f` function for repeated
* calls with an equal inputs. Returned function caches last input
* and a result of the computation for it, which is handy for
* optimizing `render` when computations are run on unchanged parts
* of state. Although note that only last result is cached so it is
* not practical to call it mulitple times with in the same `render`
* call.
*
* @param {Function} function doing computation
*
* @module shouldComponentUpdate.isEqualState
* @returns {Function} Optimized function.
* @api public
*/
return function cached (f) {
var input,
output;
Expand Down

0 comments on commit f7d4afd

Please sign in to comment.