Skip to content

Conversation

@fnesveda
Copy link
Member

Historically, functions scheduled with betterSetInterval needed to accept a callback and then call it when done, to schedule their next invocation. This was because Promises were not a thing in 2015 when this function was originally written. It's silly to have this requirement now, almost ten years later, when async/await and Promises are a normal feature.

This change adds support for scheduling any function, sync or async, accepting or not accepting a callback, and having it just work.

betterSetInterval(async () => {
    await myAsyncOperation();
}, 1000);

For backwards compatibility reasons, a dummy callback is still passed to the invoked function as its first argument, otherwise the functions that don't expect this change would break.

@fnesveda fnesveda added adhoc Ad-hoc unplanned task added during the sprint. t-core-services Issues with this label are in the ownership of the core services team. labels Dec 17, 2024
@fnesveda fnesveda added this to the 105th sprint - Platform Team milestone Dec 17, 2024
@fnesveda fnesveda requested review from B4nan and gippy December 17, 2024 19:11
@fnesveda fnesveda self-assigned this Dec 17, 2024
@github-actions github-actions bot added the tested Temporary label used only programatically for some analytics. label Dec 17, 2024
@fnesveda fnesveda force-pushed the feat/improve-bettersetinterval branch from bde0862 to 4a110c4 Compare January 3, 2025 08:23
@fnesveda fnesveda merged commit 2708964 into master Jan 3, 2025
9 checks passed
@fnesveda fnesveda deleted the feat/improve-bettersetinterval branch January 3, 2025 08:26
@fnesveda fnesveda added the validated Issues that are resolved and their solutions fulfill the acceptance criteria. label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-core-services Issues with this label are in the ownership of the core services team. tested Temporary label used only programatically for some analytics. validated Issues that are resolved and their solutions fulfill the acceptance criteria.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants