I am trying to work with a timer in Salesforce Lightning. When I add it to the page, it throws the error of "render threw an error in 'c:serviceConsoleCaseTimer' [Cannot assign to read only property 'disconnectedHandler' of object '[object Object]']" I have no clue how to fix this error. Here is the code where I am getting this error:
set tabclosed(value){
this._tabclosed = value;
this.tabisclosed = this._tabclosed;
if(this.tabisclosed){
this.disconnectedHandler();
}
}
constructor(params){
super(params)
this.disconnectedHandler = this.disconnectedHandler.bind(this)
this.pauseTimer = this.pauseTimer.bind(this)
}
connectedCallback() {
if(this.autoStart){
this.start();
}
window.addEventListener("beforeunload", this.disconnectedHandler);
}
// Function for detecting window navigation/closing
disconnectedHandler(){
if(this.stime !== '00:00:00'){
this.stop();
newSession({caseId: this.recordId, timeVal: this.stime}).then(() => {
})
.catch(error => {
});
}
}
I understand that the property is read only. I have tried to set the property writable : true as well.
Here are the links that I have tried: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Read-only https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty
https://stackoverflow.com/questions/57591012/ngrx-cannot-assign-to-read-only-property-property-of-object-object Workspace Api not returning focused tab details
Thank you for any help!
this
, effectively meaning that this code would do nothing even if it worked.