Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Created September 17, 2023 05:16
Show Gist options
  • Select an option

  • Save YonatanKra/ee9e5345b29c5eeb0d2c6ad20c258205 to your computer and use it in GitHub Desktop.

Select an option

Save YonatanKra/ee9e5345b29c5eeb0d2c6ad20c258205 to your computer and use it in GitHub Desktop.
Tauri-demo: extracted view logic
export class App extends HTMLElement{
#setViewAccordingToUserStatus = () => {
if (this.#authComponent!.isLoggedIn?.() === false) {
this.shadowRoot!.innerHTML = `<yag-login></yag-login>`;
} else {
this.shadowRoot!.innerHTML = `<yag-greeter></yag-greeter>`;
}
}
#authComponent?: HTMLElement;
constructor(){
super();
this.attachShadow({mode: 'open'});
}
connectedCallback(){
this.#authComponent = document.createElement('yag-auth') as HTMLElement;
this.#setViewAccordingToUserStatus();
this.#authComponent.addEventListener('user-status-change', this.#setViewAccordingToUserStatus);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment