Skip to content

How to set up a "read-only" firebase-document (or, "read-first") #120

@mm-gmbd

Description

@mm-gmbd

I'm building a single page application that has two tabs. A firebase-document to a particular location is called by an element on the first tab. The second tab is lazily loaded, and a firebase-document to the same location is set up by an element in that second tab.

The user only has read privileges to this location, but I'm getting the following error when the second firebase-document is loaded:

Uncaught Error: Firebase.update failed: First argument  must be an object containing the children to replace.

This is because the data attribute that is supplied to the second Firebase document is null because I am awaiting the value to be supplied by the firebase-document. Instead, it immediately updates the local cache (I think) to null, which is why I think the error is happening (as it calls _dataChanged).

I'd like a way to instantiate multiple firebase-document's that reference the same location without this happening. I had hoped to do this by binding the data from the firebase-document in such a way that it is child-to-host, but that requires the child element (in this case, firebase-document) to have the readOnly property set to true for data.

A potential solution is to include a "readOnly" property to the firebase-document itself, that, if set to true, would set the readOnly property of data to true, which would then allow for child-to-host data binding. Another solution would be to include a readFirst to firebase-document property which would read the data if it was in the local Firebase cache, if it wasn't in the Firebase cache, it would attempt to update the remote document.

Otherwise, I'm forced to load the data at location only once and then pass it around through Polymer variables (which is not going to happen because I am uncertain of how nested these elements may be), or through something like akc-meta, which I'd rather not use.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions