Open ChandreshRana opened 6 years ago
same here....
same!
You didn't read the documentation my brother.
Do it like this:
class DataObj {
@persist('list') @observable employees = [];
@persist('list') @observable equipments = [];
}
class MyStore {
@persist('object', DataObj) @observable dataObj = new DataObj();
}
We have a problem with nested, not plain arrays. { someitem: [ ] }. Like he showed in the example
We have a problem with nested, not plain arrays. { someitem: [ ] }. Like he showed in the example
LOL. I just showed you nested example. Take a look of my reply above.
@erzzo Okay. If you still don't understand. Let me explain:
Instead of doing this:
class MyStore {
@persist('object') @observable dataObj = {
employees: [],
equipments: []
}
}
...
export const myStore = new MyStore();
do this:
class DataObj {
@persist('list') @observable employees = [];
@persist('list') @observable equipments = [];
}
class MyStore {
@persist('object', DataObj) @observable dataObj = new DataObj();
}
...
export const myStore = new MyStore();
Do you still not understand?
Sorry, it's the morning :D looks good. Will try it. So just need to create an observable array then use it in the object. :+1:
I have above persist observable object and its properties employees and equipments. When I push data in employees (eg. employess = [ {}, {} ] )
Now when I reopen app, I can not get employees with data, I got only blank array.
console.log('Employees: ', store.dataObj.employees)
print => []