- From: Elad Alon via GitHub <sysbot+gh@w3.org>
- Date: Tue, 28 Sep 2021 10:16:23 +0000
- To: public-webrtc-logs@w3.org
> > ```js > > doSomething(); // Maybe ends the task, mabye doesn't. > > ``` > > Synchronous functions don't end a task, because JS is run to completion. Did you mean `await doSomething()` ? You've hit the nail on the head. `doSomething()` **is in fact** asynchronous, even if you don't `await` on it. It waits on a Promise. Sometimes it waits on an already-resolved Promise, sometimes it waits for 5s. ```js async function doSomething() { await (makeDecision() ? alreadyResolvedPromise : slowPromise); } ``` Now, it's exactly [POLA](https://en.wikipedia.org/wiki/Principle_of_least_astonishment) which I am citing here: ```js const stream1 = await navigator.mediaDevices.getDisplayMedia(); doSomething(); // Maybe ends the task, mabye doesn't. navigator.mediaDevices.focusPolicy = "no-focus"; ``` This code produces flaky results, but **cannot raise exceptions**. That's not simple. That's a problem. -- GitHub Notification of comment by eladalon1983 Please view or discuss this issue at https://github.com/w3c/mediacapture-screen-share/issues/190#issuecomment-929053124 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 28 September 2021 10:16:25 UTC