Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.
Closed
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions firebase-firestore-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@
*/
Polymer.FirestoreMixin = parent => {
return class extends parent {
static _assertPropertyTypeCorrectness(prop) {
const errorMessage = (listenerType, propertyType) =>
`FirestoreMixin's ${listenerType} can only be used with properties ` +
`of type ${propertyType}.`;
const assert = (listenerType, propertyType) => {
if (prop[listenerType] !== undefined && prop.type !== propertyType) {
throw new Error(errorMessage(listenerType, propertyType.name));
}
}

assert('doc', Object);
assert('collection', Array);
}

constructor() {
super();
this._firestoreProps = {};
Expand All @@ -140,6 +154,8 @@

connectedCallback() {
const props = collect(this.constructor, 'properties');
Object.values(props).forEach(this.constructor._assertPropertyTypeCorrectness);

for (let name in props) {
if (props[name].doc) {
this._firestoreBind('doc', props[name].doc, name, props[name].live, props[name].observes);
Expand Down