I know how to set the defaults of an object:
store.currentUser = {
username: ''
}
And set new values to it:
store.getCurrentUser = () => {
const currentUser = Parse.User.current()
store.currentUser.username = currentUser.username
}
}
But I can't do that if I have an array:
store.buildings = [
// how to set the defaults here?
]
Because the number of objects that the array can contain is unknown:
store.findBuildings = () => {
const query = new Parse.Query(Building)
return query.find({
success: (buildings) => {
// _.map(buildings, (building) => building.toJSON())
// -> [ {name: 'Name 1'}, {name: 'Name 2'}, etc... ]
// how to give the new values to store.buildings?
},
error: (buildings, error) => {
console.log('Error:', error.message)
}
})
}
Is here any way to accomplish this?
Note: I can't just do buildings = []
because I need the keys to have defaults in order for the reactivity of my app to work.