Skip to content

Instantly share code, notes, and snippets.

@davecra
Last active May 12, 2023 22:04
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/d5e2db656dd61471c2d790e6577bdec3 to your computer and use it in GitHub Desktop.
Save davecra/d5e2db656dd61471c2d790e6577bdec3 to your computer and use it in GitHub Desktop.
inline3.js
export default class MyClassToCallTheServer {
#internvalValue = null;
#loading = false;
constrcutor() {
this.#internalValue = this.#callTheServer();
}
doSomethingWithTheServerData = async () => {
while(this.#loading) await new Promise(resolve => setTimeout(resolve, 10));
// the #internalValue is not null because we waited
return this.#internalValue;
}
#callTheServer = async() => {
this.#loading = true;
// imagine some code here with a fetch command...
this.#loading = false;
return serverData;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment