Last active
May 12, 2023 22:04
-
-
Save davecra/d5e2db656dd61471c2d790e6577bdec3 to your computer and use it in GitHub Desktop.
inline3.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; | |
#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