Last active
May 12, 2023 22:05
-
-
Save davecra/c8b58d83d67e6911c3c5383d85f4306a to your computer and use it in GitHub Desktop.
inline2.js
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 default class MyClassToCallTheServer { | |
#internvalValue = null; | |
constrcutor() { | |
// this.#internalValue = await this.#callTheServer(); <-- the await will fail to compile | |
this.#internalValue = this.#callTheServer(); | |
} | |
doSomethingWithTheServerData = () => { | |
// the #internalValue is still null becasue we could not await in the constructor | |
return this.#internalValue; | |
} | |
#callTheServer = async() => { | |
// imagine some code here with a fetch command... | |
return serverData; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment