firebase-element を使用する場合、最も効果的な方法は何ですか?
各場所の新しい firebase-element。
for ループの使用。
各場所の新しい firebase-element
...
<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>
...
for ループの使用。
...
<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;
}
}
}
}
});