Skip to content

Releases: akuzko/use-stash

v2.6.0

04 Mar 23:12
Compare
Choose a tag to compare

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

14 Nov 20:34
Compare
Choose a tag to compare

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

07 Nov 14:05
Compare
Choose a tag to compare

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

09 Sep 20:48
Compare
Choose a tag to compare

Release Description

  • looger mixin now logs diff between prev data and next data using deep-object-diff package
  • fixed code sample in mixins/actionReducer section of the README

v2.4.0

05 Sep 20:42
Compare
Choose a tag to compare

Release Description

  • Added actionReducer mixin that allows to define actions with "local" reducer function and success/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 with actionReducer mixin API, and it also looks more familiar compared to React's hook dependencies.

v2.3.0

01 Sep 12:27
Compare
Choose a tag to compare

Release Description

  • Added support for dynamic paths when using useData hook, i.e. usage like
    const [itemId, setItemId] = useState(null);
    const currentName = useData(`todos.items.{id:${itemId}}.name`);
    will work as expected for dynamic 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 of useData hook.

v2.2.0

29 May 22:16
Compare
Choose a tag to compare

Release Description

  • Added except configuration option to logger mixin to allow to avoid logging of specific action calls / data reductions to prevent spamming console aoutput
  • Stability improvements
  • README updates
  • Improved example app organization

v2.1.0

23 May 21:45
Compare
Choose a tag to compare

New Features

  • Added a mixin API to add custom functionality to stashes. In addition, use-stash also provides a logger mixin out-of-the-box.
  • Added dependency on get-lookup package for path resolution. This makes usage of Stash#get and useData functions more convenient
  • See README for description of new features

v2.0.1

11 May 11:57
Compare
Choose a tag to compare

Patch Updates

  • Peer dependency on react and react-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 version 16.8.0)

New Experimental Features

  • Added experimental mixin functionality. For now, the only mixin available out-of-the-box is logger than can be required via import { logger } from "use-stash/mixins";. This functionality is not yet documented, but example usage can be seen in example app.

v2.0.0

01 May 21:33
Compare
Choose a tag to compare

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, including defAction and reduce 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 and withStash. See README for details and examples.