From b1113c3b594b650bf93ae8ac9faff2eff927566a Mon Sep 17 00:00:00 2001 From: Gerwin Sturm Date: Sun, 8 Oct 2017 22:10:25 +0200 Subject: [PATCH 1/2] Move instantiation of firestore to prevent race-problems. --- firebase-firestore-mixin.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/firebase-firestore-mixin.html b/firebase-firestore-mixin.html index a7bcc07..4d70dc6 100644 --- a/firebase-firestore-mixin.html +++ b/firebase-firestore-mixin.html @@ -169,13 +169,17 @@ this._firestoreProps = {}; this._firestoreListeners = {}; - this.db = this.constructor.db || firebase.firestore(); } connectedCallback() { + super.connectedCallback(); + if (this[CONNECTED_CALLBACK_TOKEN] !== true) { this[CONNECTED_CALLBACK_TOKEN] = true; + this.db = this.constructor.db || firebase.firestore(); + this.db.settings({timestampsInSnapshots: true}); + const props = collect(this.constructor, 'properties'); Object .values(props) @@ -188,8 +192,6 @@ } } } - - super.connectedCallback(); } _firestoreBind(name, options) { From 0f84c08012dd725ce700d311aba76c9c6cd631ac Mon Sep 17 00:00:00 2001 From: Gerwin Sturm Date: Mon, 28 May 2018 22:04:51 +0200 Subject: [PATCH 2/2] Move super.connectedCallback to original position --- firebase-firestore-mixin.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firebase-firestore-mixin.html b/firebase-firestore-mixin.html index 4d70dc6..f9ed87c 100644 --- a/firebase-firestore-mixin.html +++ b/firebase-firestore-mixin.html @@ -172,8 +172,6 @@ } connectedCallback() { - super.connectedCallback(); - if (this[CONNECTED_CALLBACK_TOKEN] !== true) { this[CONNECTED_CALLBACK_TOKEN] = true; @@ -192,6 +190,8 @@ } } } + + super.connectedCallback(); } _firestoreBind(name, options) {