Так что у меня проблема с массивами Polymer 1.0, которые не принимаются так, как ожидалось. В настоящее время у меня есть массив usersInOrg, который нужно передать в другую часть приложения. Система автоматической привязки данных работает как шарм, пока я не начну пытаться мутировать массив с добавлением объектов из внутри вложенной функции.Обновление полимерной матрицы
недвижимости:
usersInOrg: {
type: Array,
notify: true
},
Функция:
_computeUsersInOrg: function(){
/************* userIdsObjectInOrg ***********
{
uid: true
uid2: true
uid3: true
...
}
********************************************/
var userIds = Object.keys(this.userIdsObjectInOrg);
// Empty old users (just in case)
this.usersInOrg = [];
// So I can use this.notifyPath or this.usersInOrg in the firebase call
var self = this;
for (var key in userIds) {
// Where the user is found in the database
var userRef = this.baseRef + '/users/' + userIds[key];
// Create query
var firebaseRef = new Firebase(userRef);
// Here is where I should be adding my people into the array
firebaseRef.on("value", function(snapshot) {
// This comes back fine { name: Jill, age: 23, ... }
console.log(snapshot)
// For debugging purposes (number are appearing correctly)
self.notifyPath('usersInOrg', [5,6]);
// Add in the user info to the array
self.push('usersInOrg', snapshot.val());
// Let index know I added it
self.notifyPath('usersInOrg', self.usersInOrg);
})
}
}
Выход:
Users in Org: 5,6
Hello from shokka-admin-homepage
Почему объекты не добавляя к моему массиву? Он должен вывести 5,6,[Object object]
, я бы подумал.