polymerfire icon indicating copy to clipboard operation
polymerfire copied to clipboard

Move instantiation of firestore to prevent race-problems.

Open Scarygami opened this issue 8 years ago • 3 comments
trafficstars

I've run into an issue when using FirestoreElement in the same element that has firebase-app.

Accessing firebase.firestore() in the constructor happened before firebase-app had a chance to initialize the app, resulting in an error.

A workaround would have been to create a separate element with the FirestoreElement mixin to load the data and retrieve the data from there instead of using a Firestore property directly, but the error was easy enough to fix this way.

Scarygami avatar Oct 08 '17 20:10 Scarygami

Could this issue maybe get fixed? I recently ran into the same error @Scarygami described and the fix seems to be working.

stemuk avatar May 28 '18 18:05 stemuk

I've rebased this PR against the current firestore branch. This is the version I'm currently using without problems.

(Also gets rids of the "The behavior for Date objects stored in Firestore is going to change AND YOUR APP MAY BREAK." warning)

Also moved the super.connectedCallback back to the end. This move only solved issues in the original version of this mixin, which has significantly changed since then.

Scarygami avatar May 28 '18 19:05 Scarygami

I tried out your updated polymerfire firestore branch and for some reason I am still getting the no-app error, even though I have the firebase-app element imported and included in the element. Does maybe the PRPL pattern of the Polymer Starter Kit tamper with the firebase-app initialization?

stemuk avatar May 29 '18 10:05 stemuk