Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.
Open
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
844dcfd
added exists attribute, reflecting whether we have data at a given pa…
christophe-g Jun 17, 2017
5274aeb
Merge branch 'master' into knowIfExists
christophe-g Sep 7, 2017
91d7793
Update README.md
imarian97 Oct 6, 2017
15f1c8a
Merge pull request #277 from imarian97/patch-1
tjmonsi Oct 7, 2017
f6df335
Fix typo in code
FluorescentHallucinogen Nov 4, 2017
f107307
Merge pull request #305 from FluorescentHallucinogen/patch-2
tjmonsi Nov 5, 2017
f6b0b14
integrate @merlinnot comments
christophe-g Jan 13, 2018
58ed184
integrate @merlinnot comment
christophe-g Jan 13, 2018
c8e301c
integrate @merlinnot comments
christophe-g Jan 13, 2018
ac153f4
Merge branch 'master' into knowIfExists
christophe-g Jan 13, 2018
ab634d9
Merge branch 'master' into knowIfExists
christophe-g Jan 13, 2018
7290611
added tests
christophe-g Jan 13, 2018
a7e445e
Fix indentation in test files.
merlinnot Jan 13, 2018
6ca00b6
Merge pull request #234 from christophe-g/knowIfExists
tjmonsi Feb 21, 2018
ba6a8e8
Merge pull request #312 from merlinnot/fix-issue-311
tjmonsi Feb 21, 2018
7ea2df2
Race condition prevention.
Westbrook Feb 21, 2018
7ff8a37
Prevent collection paths with multiple arguments from triggering mult…
Westbrook Feb 23, 2018
a3f9653
Merge branch 'master' into firestore
Westbrook Feb 24, 2018
63cbcaa
`_firestoreUpdateBinding` every `_firestoreBind`
Westbrook Feb 25, 2018
fd337f1
Lazily unlisten and create DB
Westbrook Feb 25, 2018
24e2d64
Move unlisten back to before the "ready" check
Westbrook Feb 28, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions firebase-firestore-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,11 @@

this._firestoreProps = {};
this._firestoreListeners = {};
this.db = this.constructor.db || firebase.firestore();
}

connectedCallback() {
super.connectedCallback();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask why did you decide to move it here? What’s the reasoning behind it?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mainly stole these two lines from #279, but the goal is to not have an issue like this: https://receptive-kitten.glitch.me/ I can look into what this is actually fixing soon.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it actually needed to fix it? I can’t really see why would it help.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, finally got into this part more. It helps because if you allow super.connectedCallback() to run, then the code at https://github.com/firebase/polymerfire/blob/master/firebase-app.html#L123 will also be allowed to fully run, which means that the app will have actually connected to Firebase. It's possible that you suggestions on moving some of the this.db stuff out to the scope might address this as well. However, were that not so, maybe this is a use case for https://www.polymer-project.org/2.0/docs/api/namespaces/Polymer.RenderStatus#function-Polymer.RenderStatus.afterNextRender ?

this.db = this.constructor.db || firebase.firestore();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we ever have this.constructor.db defined? I think we could improve it even further:

  • actually lazy-require Firestore (if binding is called with all props defined, line 231?)
  • introduce a helper method for this
  • we could move it out of the mixin entirely (to the scope), unless we want to give an access to db prop, then we would need to make some docs for it

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we ever have this.constructor.db defined?

Doesn't seem so...copy pasta.

actually lazy-require Firestore (if binding is called with all props defined, line 231?)

Yes a this.db = this.db || firebase.firestore(); there would seem sufficient.

we could move it out of the mixin entirely (to the scope), unless we want to give an access to db prop, then we would need to make some docs for it

I'm not quite sure I follow.

if (this[CONNECTED_CALLBACK_TOKEN] !== true) {
this[CONNECTED_CALLBACK_TOKEN] = true;

Expand All @@ -188,8 +189,6 @@
}
}
}

super.connectedCallback();
}

_firestoreBind(name, options) {
Expand All @@ -211,9 +210,9 @@
const observer =
`_firestoreUpdateBinding('${name}', ${args.join(',')})`
this._createMethodObserver(observer);
} else {
this._firestoreUpdateBinding(name, ...args.map(x => this[x]));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two issues here:

  • this won’t work if the values of properties are set before we create a method observer
  • even if it would work, we have a guarantee that args will have no items, so mapping over this is unnecessary

@Westbrook Westbrook Feb 24, 2018

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this won’t work if the values of properties are set before we create a method observer

I can see how this might be an issue, but I'm not sure that the timing requisite of such a reality is possible with the code order of a Polymer component. Can you point me to how you envisioned that being possible?

even if it would work, we have a guarantee that args will have no items, so mapping over this is unnecessary

Good point, I can clean that up when you think this is going towards a solution.

}

this._firestoreUpdateBinding(name, ...args.map(x => this[x]));
}

_firestoreUpdateBinding(name, ...args) {
Expand Down