After localStorage.clear() or deleteRecord() in my Ember.js app, local storage data are resurrected

后端 未结 2 1124
我在风中等你
我在风中等你 2021-01-13 20:13

I\'m observing a data resurrection after localStorage.clear() or deleteRecord() (jsbin example) is called in my ember app.

Follow these ste

相关标签:
2条回答
  • 2021-01-13 20:39

    Problem fixed in September's version of Ember Data/Local Storage. See it in action in this SO Answer with a jsbin.

    After some discussions with folks on IRC, there is currently a bug in LSAdapter or in Ember Data that causes the data to linger around.

    The problem is on pause as of August 2013 due to imminent changes in Ember Data.

    The work-around for this problem is to both clear the Local Storage as well as the ember data. See it working in this jsbin.

    Alternatively, you can immediately call location.reload() after clearing local storage to show the fresh data.

    0 讨论(0)
  • 2021-01-13 20:53

    Wiping localStorage with clear works just OK. It is your local storage adapter (LSAdapter) that keeps the state and repopulate previously cleared localStorage on creating new record. This is done that way because records are stored in a string and LSAdapter don't know if you've changed it or not, so it always save all the records to be sure it is synced.

    Consider destroying all the records instead of clearing localStorage.

    0 讨论(0)
提交回复
热议问题