0

I'm trying to handle a callback for firebase-query so that I can do some local filtering. I'm using polymerfire, specifically firebase-query web component to get all records in a particular path. Below is the usage

 <firebase-query  
        id="query"
        path="/Reports"
        data="{{allReportsData}}">
 </firebase-query>

Inside script tag

Polymer({

        is: 'pencco-app',

        properties: {
            allReportsData: {
                type: Object,
                notify: true,
                observer: 'dataChanged'
            }
        }
....

Problem is that the observer is not getting called.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Tushar Nallan
  • 784
  • 6
  • 16

1 Answers1

2

Try changing your observer like this

Polymer({

    is: 'pencco-app',

    properties: {
        allReportsData: {
            type: Object,
            notify: true
        }
    },
    observers: [
        'dataChanged(allReportsData.*)'
    ]
....

The following link explains the deep linking required to observer changes to object properties: https://www.polymer-project.org/1.0/docs/devguide/observers#deep-observation

  • Problem is that it wont give me all the data at once. The above generates multiple events for a single data change. So using above code, for getting an array on n items, I'll have n "splice" events and n "length" events in my listener – Tushar Nallan Aug 26 '16 at 06:53
  • 1
    True. But that is how the Firebase Query works. That is "by design" behaviour. If you want all the data at once without an event listener then you should initiate a query against the REST endpoint. The whole point of that element is to facilitate the real-time capabilities so it listens for data change events on the DB. You won't get all the data at once with the firebase-query element. – Ian Edwards Aug 27 '16 at 13:27