adopted-ember-addons / adopted-ember-addons/ember-local-storage
Creating new nested key
- Lenguaje dominante
- JavaScript
- Estrellas
- 220
- Forks
- 78
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
I have a settings local-storage model with nested attributes. This is working great, but when trying to add more attributes I'm confused as to why the ember-local-storage plugin isn't simply creating the new key for the missing nested attribute. For example:
My settings when project was first launched in the browser:
```
lastWifi: false,
lastConnected: null,
settings: {
language: 'en',
about: {
version: "0.5"
}
}
```
This created a localStorage object, works like a charm. However in developing the app, I need to add more nested keys.
```
lastWifi: false,
lastConnected: null,
settings: {
language: 'en',
about: {
version: "0.5"
},
bluetooth: {
allow: true
}
```
When trying to access the bluetooth and it's allow key, I'm getting this error:
```
ember.debug.js:19818 Property set failed: object in path "settings.bluetooth" could not be found or was destroyed.
Error
at setPath (http://localhost:4200/assets/vendor.js:35584:15)
at Object.set (http://localhost:4200/assets/vendor.js:35504:14)
at Class.set (http://localhost:4200/assets/vendor.js:48371:26)
at Class.saveIfChanged (http://localhost:4200/assets/vendor.js:74170:17)
at Class.superWrapper [as set] (http://localhost:4200/assets/vendor.js:54095:22)
at Class.toggleSetting (http://localhost:4200/assets/www.js:1207:30)
at Backburner.join (http://localhost:4200/assets/vendor.js:13883:21)
at Function.run.join (http://localhost:4200/assets/vendor.js:35754:28)
at http://localhost:4200/assets/vendor.js:23468:37
at Object.flaggedInstrument (http://localhost:4200/assets/vendor.js:31850:14)
```
I understand I could use the `.isInitialContent()` `.clear()` or `.reset()` functions, however I would then have to do this for every update I deploy or on every new key I add? Seems somewhat counter productive and could lead to a bad user experience.
I've now added my local-storage to a model, as recommended for nested attributes. However the behavior does not change.
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.