How to get max performance getting data using the firebase-element?

102 views Asked by At

When using the firebase-element, what is considered the most effective method?

  1. New firebase-element for each location.

  2. Using a for loop.

New firebase-element for each location

...
<firebase-element location="https://YOUR-FIREBASE.firebaseio.com/users"></firebase-element>
<firebase-element location="https://YOUR-FIREBASE.firebaseio.com/products"></firebase-element>
<firebase-element location="https://YOUR-FIREBASE.firebaseio.com/info"></firebase-element>
...

Using a for loop.

...
<firebase-login location="https://YOUR-FIREBASE.firebaseio.com/" user="{{fbUser}}"></firebase-login>
<firebase-element location="https://YOUR-FIREBASE.firebaseio.com/" data="{{fbData}}" dataReady="{{dataReady}}"></firebase-element>
...
Polymer({
    data: null,
    user: null,

    observe: {
        'fbData': 'syncData',
        'fbUser dataReady': 'syncUser'
    },

    syncData: function() {
        if(this.data.products !== this.fbData.products) {
            this.products = this.fbData.products;
        }
    },

    syncUser: function() {
        if(this.fbUser && this.dataReady) {
            for(var user in this.fbData.users) {
                if(this.fbData.users[user] === this.fbUser.uid) {
                    this.user = this.fbData.users[user];
                } else {
                    this.user = null;  
                }               
            }
        }            
    }
});
0

There are 0 answers