polymer js 3.0 constructor calling twice issue in component

19 views
Skip to first unread message

nishanth....@gmail.com

unread,
Jan 30, 2019, 7:00:48 AM1/30/19
to Polymer
Hi, we are developing a web app using pwastater kit and polymer js 3.0,i am facing an issue once my component is invoked the constructor is calling two times because of this my login service is calling twice, i am placing my login component in my-app component. please find the below code snippet of my login component.

import { LitElement, html } from '@polymer/lit-element';
import { GetLoginJwt } from '../../framework/repository/jwt.repository.js';
import { BindMessageListener } from '../../framework/services/frame-message-listener.service.js';
import { AppConstants } from '../../framework/constants/app.constants.js';
import { LogInPopUp,IsUserLoggedIn,GetPopUpHtml } from '../../components/message-popup.component.js';
import {ExceptionHandlerService} from '../../framework/services/exception-handler.service'
import {ExceptionModel} from '../../framework/models/exception-data.model.js'

class Login extends LitElement {
render(props) {
return html`
`;
}
static get properties() {
return {
LoginURL: { type: String }
}
}

constructor() {
super();
if(document.getElementById("paperDialogBox")==null){
LogInPopUp();
IsUserLoggedIn().then(status=>{
if(!status){
this.LoginURL = "about:blank";
loginModelPopup.open();
this.GetLoginURL();
}
});
}
}

GetLoginURL() {
this.GenerateLoginUrl();
}

async GenerateLoginUrl() {
var encryptedJwt = '';
await GetLoginJwt().then(data => {
encryptedJwt = data;
});
let appConstants = new AppConstants();
this.LoginURL = appConstants.LoginUrl + encryptedJwt;
loginIframe.setAttribute('src',this.LoginURL);
BindMessageListener();
}

}

window.customElements.define('login-page', Login);

Thanks
Nisanth

Ben Sisakht

unread,
Jan 30, 2019, 10:44:53 AM1/30/19
to Polymer
Hey, it would be great if you could add your my-app.js as well where you add your login-page. It looks like to me that there are two instances of login-page otherwise the checks you have implemented would prevent the second login page to be called. So my guess is somewhere/somehow you are instantiating two login-pages and it's not that constructor is being called twice in the same instance of login-page. Cheers
Reply all
Reply to author
Forward
0 new messages