Reputation: 944
I am learning Polymer. So far I love it, but this has me stumped. I am using Firebase for the back end of an app I am developing.
I have the following code:
<!doctype html>
<html>
<head>
<script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="bower_components/firebase-element/firebase-auth.html">
</head>
<body>
<template is="dom-bind" id="my-template">
<firebase-auth id="firebase"
user="{{user}}"
status-known="{{statusKnown}}"
location="https://****.firebaseio.com"
provider="password"
on-error="onError"
on-login="onSuccess"
on-logout="onSuccess">
</firebase-auth>
<div>status: {{statusKnown}}</div>
<div>user: {{user.uid}}</div>
<button on-tap="login">login</button>
<button on-tap="logout">logout</button>
</template>
<script>
document.addEventListener('WebComponentsReady', function() {
var template = document.getElementById('my-template');
var fb = document.getElementById('firebase');
template.login = function() {
fb.login({email: '[email protected]', password: 'password'});
};
template.logout = function() {
console.log('logout', this);
fb.logout();
};
template.onError = function(e) {
console.log('onError', e);
};
template.onSuccess = function(e) {
console.log('onSuccess', e);
};
});
</script>
</body>
</html>
When I click "login", I see this in the console:
onSuccess Event {isTrusted: false, detail: Object}
onSuccess Event {isTrusted: false, detail: Object}
My question is, why does onSuccess fire twice?
Upvotes: 0
Views: 349
Reputation: 1173
This is a known issue which is waiting answer: https://github.com/GoogleWebComponents/firebase-element/pull/67
You can work normally with Firebase apart from that.
If you are interested, please take a look also here, I am creating a set that will extend the basic functionalities of Firebase: https://github.com/MeTaNoV/firebase-element-extended
Upvotes: 2