Created
September 17, 2023 05:16
-
-
Save YonatanKra/ee9e5345b29c5eeb0d2c6ad20c258205 to your computer and use it in GitHub Desktop.
Tauri-demo: extracted view logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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