Got a question here.
I have a component that needs to poll an api every 2 seconds.
To achieve the "wait to seconds part" I have a very simple util function that you call with the amount of time to sleep and will return a promise that resolves in the specified amount of time.
With this util, my component can just do await sleep(2000)
on a while loop to poll the api.
My question is, what happens if the component gets destroyed while it is waiting for the promise to resolve? Would the promise resolve and continue the execution of the method? Would the promise just be orphaned and once it resolves it will be a no-op? Would this somehow cause a memory leak?
Please let me know if I need to provide more details.