Closed liby closed 2 years ago
You're seeing consistent behavior because your implementation of fetchURL
is synchronous. If you make it async (but without declaring it async
):
function fetchURL(url: string, cb: (response: string) => void) {
setTimeout(() => {
cb(url);
}, 10);
}
Then you can call getUser("test")
twice and observe different behaviors.
Here's an updated version of your playground link.
Chapter 25 has the following description:
Playground
In fact,
requestStatus
will be set tosuccess
and then toloading
regardless of whether theprofile
is cached or not.