I want to have a polymer element which shares an array to all instances. THis is possible if I do not use a function to instantiate the array. This works fine. BUt when I change the array Elements with this.push("ArrayPath", Value), than only the current instance is notified, but not all. What I want todo is to have a computed boolean property, which listens to the array change, what I have:
Polymer({
is: 'data-holder',
properties: {
editedFields: {
type: Array,
notify: true,
value: []
},
unsaved: {
type: Boolean,
notify: true,
reflectToAttribute: true,
computed: '_isUnsaved(editedFields.*)'
}
},
_isUnsaved: function(array) {
return (array.base.length > 0) ? true : false;
},
_addItem: function(value) {
this.push("editedFields", value);
},
....
ok so far so good. With _addItem function I add an item to the editedFields array and my _isUnsaved function gets called. This is fine. But this is only called within this instance where I call the _addItem method. the array "editedFields" is changed in all instances, but the "unsaved" property is only notified within the current instance?
How can I manage it to get all instances listen to the array change? So that all instances get the attribute "unsaved" to the element declaration?
btw. the value parameter of the _addItem method is an object to ensure uniqueness