with this query by default the nodes from /users are updated in realtime to the array "patients". so you can use this immediatly without writing any observer or so on e.g. in a dom-repeat element. this element is updated when more nodes come in the query.
anyway
if you want to observe this array for changes ( and modify the data afterwards ) you need to set a observer in the properties block like so:
static get properties() {
return {
patients: {
// use only one of these types:Boolean | Number | String | Array | Object,
// in your case i think its an Array
type: Array
// For an Array or Object, you must return it from a function
// (otherwise the array will be defined on the prototype
// and not the instance):
value: function() { return [] },
// other elements need to get informed if the value changes? then add this
// line:
notify: true,
// now set the observer
observer: '_patientsChanged',
},
}
}
// and the observer function itself:
_patientsChanged(newVal, oldVal){
// do whatever you want to do e.g. Log the change of the Variable in the
// Console:
console.log('Variable patients changed: It had this value: ');
console.log(oldVal);
console.log('And now it has this Value:');
console.log(newVal);
}
Kind regards
chwzrlee