Skip to content

Instantly share code, notes, and snippets.

@davecra
Last active May 12, 2023 22:04
Embed
What would you like to do?
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