Releases: akuzko/use-stash
Releases · akuzko/use-stash
v2.6.0
Release Description
- Added data mapper-on-access functionality for additional optimization. This allows to use pre-processed stash value and re-render component only when this processed value changes. For example:
function TodoIndicator() {
const allDone = useData("todos.list.items", (items) => {
return items.every(item => item.status === "completed");
});
// ...
}
The third argument of useData
hook is comparator function that should be used when mapper function returns arrays or objects.
v2.5.2
Patch Description
- Internal "storage" part of the package was refactored for better maintainability and to ensure that data subscription handlers are called in the same order they were declared in components, from parents to children.
- In addition, if any component is subscribes to a data via dynamic data path (i.e. it is unsubscribed and re-subscribed whenever path is changed), index of it's subscription handler is kept as it was for even better stability and predictable behavior.
- Basically, this release is continuation (and hopefully, logical ending) of the work started in
v2.5.1
v2.5.1
Patch Description
- Fixed internal behavior on cleaning up data listeners on component unmount: when removing last key of listeners for a specific key in
storage
, do not remove key itself. Otherwise, when re-populated, listeners can be traversed in different order compared to the one they were initially populated, resulting in weird and erroneous behavior.
v2.5.0
Release Description
looger
mixin now logs diff betweenprev data
andnext data
using deep-object-diff package- fixed code sample in
mixins/actionReducer
section of the README
v2.4.0
Release Description
- Added
actionReducer
mixin that allows to define actions with "local" reducer function andsuccess
/failure
helpers. This reducer functions keep name of the action they are referenced to and generate corresponding descriptors for convenient logging and development. - Added alternative way of specifying reducer descriptor when using
logger
mixin: first argument can be name, followed by reducer function, and the rest of dependencies can be specified as third argument. This way is more consistent withactionReducer
mixin API, and it also looks more familiar compared to React's hook dependencies.
v2.3.0
Release Description
- Added support for dynamic paths when using
useData
hook, i.e. usage likewill work as expected for dynamicconst [itemId, setItemId] = useState(null); const currentName = useData(`todos.items.{id:${itemId}}.name`);
itemId
- Dropped support for data mapper (getter) optional argument for
useData
hook. This feature had no real use, and it's support adds unnecessary complexity to proper implementation ofuseData
hook.
v2.2.0
v2.1.0
New Features
- Added a mixin API to add custom functionality to stashes. In addition,
use-stash
also provides alogger
mixin out-of-the-box. - Added dependency on
get-lookup
package for path resolution. This makes usage ofStash#get
anduseData
functions more convenient - See README for description of new features
v2.0.1
Patch Updates
- Peer dependency on
react
andreact-dom
packages was loosen to^16.8.x
, instead of^16.8.6
to allow usage within any app that uses react's hooks (that are supported as of version16.8.0
)
New Experimental Features
- Added experimental
mixin
functionality. For now, the only mixin available out-of-the-box islogger
than can be required viaimport { logger } from "use-stash/mixins";
. This functionality is not yet documented, but example usage can be seen in example app.
v2.0.0
Breaking Changes
- Changed Stash definition API: now it's a mix of original
defStash
method and what was called "Advanced Usage", i.e.defStash
function accepts namespace name, initial data value and yields stash instance to setup function. All necessary helper functions, includingdefAction
andreduce
can be destructured from it in any appropriate order. See README for details and examples.
New Features:
- Added HOC helpers to support non-hook class-based React components. Namely,
withData
,withActions
andwithStash
. See README for details and examples.