Skip to content

Instantly share code, notes, and snippets.

@davecra
Last active May 12, 2023 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davecra/c8b58d83d67e6911c3c5383d85f4306a to your computer and use it in GitHub Desktop.
Save davecra/c8b58d83d67e6911c3c5383d85f4306a to your computer and use it in GitHub Desktop.
inline2.js
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