1

I have this below service console tab. On the right side i have added a lwc

enter image description here

on page refresh if i try to swtich between tabs i can see connectedcallback and renderedcallback is getting called. but 2nd time if i am swtiching, its not getting called. Its like getting cached. Is there any way to call lwc component everytime i swtich between tabs, These are standard Case tabs.

I have tried the below code

import { LightningElement, wire, api, track } from 'lwc';
import { CurrentPageReference, NavigationMixin } from "lightning/navigation";

export default class Casetestlwc extends  NavigationMixin(LightningElement) {
    connectedCallback() {
        alert('connected callback called')
    }

    renderedCallback(){
        alert('rendered callback called')
    }

    @track currentPageReference;
    @wire(CurrentPageReference)
setCurrentPageReference(currentPageReference) {
    this.currentPageReference = 'Welcome to the tab ' + (new Date().getTime())
    console.log('Welcome to the tab ' + (new Date().getTime()) );
}
}

HTML

<template>
   <p>{currentPageReference}</p>
</template>

1 Answer 1

0

Its like getting cached.

It's not like it's getting cached, it is getting cached. This is a performance enhancing feature.

Is there any way to call lwc component everytime i swtich between tabs, These are standard Case tabs.

In summary, you can subscribe to the various tab events and react to those events. On connectedCallback, you will subscribe to the various events that you want to listen for (probably lightning__tabFocused), and perform any logic after you receive the event in the handler.

See lightning-message-service, Subscribe to Aura Application Events in LWC, Define the Scope of the Message Service more information.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .