2016-10-27 23 views
0

如果在下面的代碼位置(firebaseURL)包括用戶的值(如auth.uid),然後火力 - 收集數據將從firebase-auth登錄刷新。我使用的聚合物1.6.0火力收集將不刷新上火力-AUTH登錄數據,如果位置不包括用戶值

<firebase-auth id="auth" 
     location="[[firebaseURL]]" 
     provider="{{provider}}" 
     params="{{params}}" 
     user="{{user}}"> 
    </firebase-auth> 

    <firebase-collection 
     location="[[firebaseURL]]" 
     data="{{messages}}"> 
    </firebase-collection> 

這是因爲登錄的火力點,權威性的用戶價值變動和改變位置值,刷新數據從火力點收集來了。

但是,如果位置路徑不包括用戶值時,數據將無法​​在登錄顯示出來,你將不得不刷新頁面要做到這一點。

我發現到目前爲止解決這個限制的唯一方法是有點駭人聽聞。

我不得不修改火力收集html代碼如下:

<firebase-collection 
     location="[[_location(user)]]" 
     data="{{messages}}"> 
    </firebase-collection> 

添加這樣的_location()函數,迫使火力收集數據刷新,並顯示了導通登錄

_location: function(u){ 
    // hacking - to trigger the update firebase-collection/document on-login/on-user-change 
    return this.user ? this.firebaseURL : ""; 
    } 

它的作品,但它看起來不正確。

有沒有更好的方法,更聚合的方式?

感謝

AskPolymer

回答

1

你可以使用一個dom-if郵票firebase-collection有條件的user

<template is="dom-if" if="[[user]]" restamp> 
    <firebase-collection 
    location="[[firebaseURL]]" 
    data="{{messages}}"> 
    </firebase-collection> 
<template>