Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix): handle non-existent key in storage
- if key is falsey, i.e. when storage has been cleared or has yet to be set to initial state, applySnapshot will fail and throw an error - so don't apply it if falsey, just skip the applySnapshot call - was thinking of applying `{}`, an empty object, if falsey, but this will reset the initial state of the store to its defaults - one might set initial state in `create({ ... })`, so that alternative doesn't work - getting the initial snapshot and setting it to itself was another alternative considered, but that would be quite complex with unnecessary operations, and might cause some unintended behavior due to whitelists, blacklists, etc applying - still need to think about the ramifications of those since applySnapshot doesn't merge, it just sets (and defaults are applied on top) - see also #1
- Loading branch information