Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error events firing and handling #340

Open
FluorescentHallucinogen opened this issue Apr 8, 2018 · 2 comments
Open

Improve error events firing and handling #340

FluorescentHallucinogen opened this issue Apr 8, 2018 · 2 comments

Comments

@FluorescentHallucinogen
Copy link
Contributor

If I use plain Firebase JavaScript SDK API, I deal with JS promises and can easily handle success and errors:

firebase.database().ref(`/posts/${postId}`).set({
  body: text
}).then(response => {
  // do something
}).catch(error => {
  // handle error
});

But if I use e.g. <firebase-document>, how do I know if the data was successfully written to the database or an error occurred (and which one)?:

<firebase-document
    path="/posts/[[postId]]/body"
    data="{{text}}">
</firebase-document>

Seems, only <firebase-auth> web component can fire error events:

<firebase-auth
    provider="google"
    user="{{user}}"
    on-error="handleError">
</firebase-auth>

But error event is not listed in https://webcomponents.org/element/firebase/polymerfire/elements/firebase-auth#events.

The following JSDoc annotation should be added to <firebase-auth> source code to fix it:

/**
 * Fired when an error occurs.
 *
 * @event error
 * @param {Object} The returned error object.
 */

What about adding error events to other PolymerFire web components? And how to handle success? What about adding success events?

@FluorescentHallucinogen
Copy link
Contributor Author

@tjmonsi @mbleigh PTAL.

@FluorescentHallucinogen
Copy link
Contributor Author

@merlinnot PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant