-
-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Handle deferred processing when document
is hidden
#402
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
96213a4
Revert back to `requestAnimationFrame`/`setImmediate`
afshin faad187
Add schedule/unschedule to coreutils
afshin 7396ad7
Use schedule/unschedule from coreutils
afshin 08c9577
Use schedule/unschedule from coreutils in Poll
afshin a6bdaae
Add support for hidden poll detection and lingering, add tests
afshin 9f50a16
Update API and fix IIFE example
afshin 28a0607
Use named type instead of ReturnType<typeof...>
afshin a85cacb
Switch back to getter/setter for standby
afshin 32b3f9e
Add explication comment for ScheduleHandle type
afshin 856f917
Tweak schedule test
afshin 03494c8
Add `background` flag to `schedule` and `unschedule`
afshin 0af044f
Add `background` support for `MessageLoop`
afshin ea7105b
Always allow polling to occur in the background
afshin 5e88995
Update API
afshin a80ddbc
Update to `setBackground` and `getBackground`
afshin f9fbdac
Handle background message loop processing internally without exposing…
afshin 6a11f9f
Cache hidden flag instead of checking the DOM every tick
afshin fdb7114
Add explanatory comment
afshin 122025c
Update API
afshin 1fb47e0
Remove schedule/unschedule from coreutils
afshin aa63e0b
Use a private schedule function that is promise-backed for the messag…
afshin 7ccb59b
Switch back to setTimeout for polls, but keep the protected hidden flag
afshin 871b771
Update API
afshin b29e1a0
Remove superfluous import from iife example, update packages and tsco…
afshin a43acf4
Change names back
afshin 0af20de
Update packages/polling/src/poll.ts
afshin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in last weeks lab dev meeting, using a Promise or async will schedule the task as a microtask, compared to
requestAnimationFrame
/setTimeout
etc that will schedule it as a macro task. This difference is likely to be significant (@afshin has the details).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is safe in this circumstance because message propagation is both lightweight and synchronous. This is the reason why the same technique is unavailable to us in
Poll
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I wanted to give @vidartf a chance to look, but I'm happy to move ahead.