Skip to content

[Feature Request] An option to have consistent timeout in unfocused windows using web workers #77

@Piratux

Description

@Piratux

Is your feature request related to a problem? Please describe.
I am using browser to run an app, where browser most of the time stays unfocused. My app uses timeouts, and I require those timeouts to not be throttled by unfocused browser. When browser is unfocused, even 1 second timeout may never finish, until browser gets focused again.

For this purpose, I use setTimeout from worker-timers.

However, I run into a pattern where I sometimes require "wait until" pattern to be used. For that, I've chosen, to use this library. But unfortunately this library doesn't have an option to run timeouts using web workers.

Describe the solution you'd like
An option to indicate, to run timeouts (both options.timeout and options.intervalBetweenAttempts) using web workers. Perhaps an option such as passing options.useWorkerTimeout: boolean could be used, where false (default value) would indicate to run native timeout, and true would indicate to run using worker timeout.

As for implementation, you could choose to use worker-timers library.

Describe alternatives you've considered
Not using this library, and implementing waitUntil myself to use web worker timeouts. However, I thought someone else may benefit if this was part of the library.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions