Search code examples
firebasepolymerfirebase-realtime-databasepolymerfire

Polymerfire - Read document once


I was wondering if there is a way to retrieve a document just once, and avoid every kind of bidirectional sync with the database.

The Polymerfire documentation is poor, and I couldn't find it.

Thanks


Solution

  • No, the firebase-document element does not have a 'once' mode. However, you can easily drop down to the underlying JS SDK if you've already initialized the SDK with firebase-app:

    Polymer({
      is: 'my-element',
      attached: function() {
        firebase.database().ref('/path/to/doc')
          .once('value').then(snap => this.data = snap.val());
      }
    });