content icon indicating copy to clipboard operation
content copied to clipboard

chore(docs) change example to use eventListener instead of polling

Open bsmth opened this issue 3 years ago • 2 comments
trafficstars

The existing example uses polling every 300 millis, it's noted in the linked issue that we can use eventListeners instead.

Notes: This example could be improved in general as we're using an iframe, so we might not even need to open a new window. We have the demonstrated effect by clicking inside the iframe and the embedding document.

Fixes #10312

bsmth avatar Nov 02 '22 17:11 bsmth

Preview URLs

(this comment was updated 2022-11-17 17:54:21.727671)

github-actions[bot] avatar Nov 03 '22 18:11 github-actions[bot]

isn't that pointless, since we know what the answer is going to be?

Very true. I'll have a think about it and circle back to this again.

bsmth avatar Nov 04 '22 08:11 bsmth

Hi @wbamberg I've taken another shot at it. Polling makes more sense than an eventListener, so I've reverted to the original here unless there's a better way of doing it I'm not thinking of.

bsmth avatar Nov 17 '22 17:11 bsmth

Hi @wbamberg I've taken another shot at it. Polling makes more sense than an eventListener, so I've reverted to the original here unless there's a better way of doing it I'm not thinking of.

The only alternative I can think of is to have an additional button saying "Check in 2 seconds". So rather than polling all the time, you push the button and then push "Open new window", then it checks.

But I think this is probably worse!

  • it's a more complicated example to understand
  • the user interaction is more complicated
  • you have to give the window focus when you click the button, which makes it weird

wbamberg avatar Nov 17 '22 18:11 wbamberg

  • user interaction is more complicated

+1 on that. Out of the variations I was trying, the current one is the most self-explanatory, I think. I'm fine with the changes in this PR for now.

bsmth avatar Nov 18 '22 11:11 bsmth