content
content copied to clipboard
chore(docs) change example to use eventListener instead of polling
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
Preview URLs
(this comment was updated 2022-11-17 17:54:21.727671)
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.
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.
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
- 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.