1

firebase-document을 사용하여 Firebase에서 데이터를 가져와야합니다. 이후 추가 처리가 필요합니다. 응답 페이로드를받습니다. 어떻게해야합니까?firebase-document를 사용하는 모든 예제

I read the documentation here, but there are no examples. transactionsComplete이라는 속성이 있지만 다시 예제가 없습니다. promise이므로 구현 방법이 불확실합니다.

누군가는 트랜잭션이 완료 후 요청 및 에 의해 반환 된 데이터를 처리 할 firebase-document의 속성 또는 메서드를 사용하는 방법의 작업 코드 예제를 제공 주실 래요? 재산 data="{{object}}"에 객체를 바인딩

<firebase-document 
    id="doc" 
    app-name="my-app"> 
</firebase-document> 
<script> 
    _userChanged: function(u) { 
    if(u) { 
     var doc = this.$.doc; 
     var path = [ 'users' , u.uid ].join('/'); 
     doc.path = path; // this should send a request for data 
     // but how do I ensure to process what is returned 
     // after and only after it comes back? 
    }     
    }, 
</script> 

답변

2

당신은 firebase-focument 방법 getStoredValue(path); (ES6 스타일)

this.$.doc.getStoredValue(path) 
    .then((response) => { 
     console.log(response); 
    }); 
를 사용하여 최종 값

<firebase-document 
    path="https://stackoverflow.com/users/{{userId}}/notes/{{noteId}}" 
    data="{{noteData}}"> 
</firebase-document> 

을 반환 할 것이다 observer 또는 계산 된 속성을 추가 할 수 있습니다

1
<!-- setup firebase-document (node) --> 
<firebase-document 
    path="/dummy" 
    data="{{dummy}}"> 
</firebase-document> 

<paper-input 
    id="dummy" 
    name="dummy" 
    label="Dummy Text" 
    value={{dummy.text}}> 
</paper-input> 

또는 변수에 액세스하려면 javascriptfunction 안에 this.dummy을 사용할 수 있습니다.

Polymer의 데이터 바인딩을 사용하므로 값이 firebase로 업데이트됩니다.