Akita: [persistState] - local storage replaced by initial state after page refresh

Created on 17 Jul 2018  路  5Comments  路  Source: datorama/akita

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior


I use persistState to persist store state through page refreshs (i.e auth token). After first page refresh, store state gets loaded correctly in memory (store), but local storage is replaced by store initial state. After a second refresh, both memory and local store contains initial state.

Expected behavior


State in local storage remain over multiple pages refreshs

Minimal reproduction of the problem with instructions


Source code here

Environment


Angular version: 5.2.6

Browser:

  • [X] Chrome (desktop) version 67.0.3396.99 (64 bits)
  • [ ] Chrome (Android) version XX
  • [ ] Chrome (iOS) version XX
  • [ ] Firefox version XX
  • [ ] Safari (desktop) version XX
  • [ ] Safari (iOS) version XX
  • [ ] IE version XX
  • [ ] Edge version XX

For Tooling issues:

  • Node version: 8.11.1
  • Platform: Linux Mint
bug

All 5 comments

Thanks for the report. I will check it soon.

A new version is on the way; please let me know when you test it. Thanks.

:tada: This issue has been resolved in version 1.2.2 :tada:

The release is available on npm package (@latest dist-tag)

Your semantic-release bot :package::rocket:

Very good. It's working! Thank you!

I like your code. By the way, you can do this:

favorites$ = this.selectAll({ filterBy: l => l.isFavorite })).pipe(distinctUntilChanged(isEqual));

instead of:

favorites$ = this.selectAll().pipe(map(lines => lines.filter(l => l.isFavorite)), distinctUntilChanged(isEqual));

Also, you gave me inspiration for the regular stores. Updated the CLI. Regular stores didn't output a model file and added create initial state function for them.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stherrienaspnet picture stherrienaspnet  路  3Comments

mikejr83 picture mikejr83  路  6Comments

eitanfr picture eitanfr  路  4Comments

simeyla picture simeyla  路  7Comments

zvnt picture zvnt  路  6Comments