-
Notifications
You must be signed in to change notification settings - Fork 48
Add dedicated service for managing timers (setInterval and setTimeout)
#2298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add dedicated service for managing timers (setInterval and setTimeout)
#2298
Conversation
|
Niiice! Haven't tested yet, but as an initial thought, is it possible to / does it make sense to prevent custom actions and the like from using the base calls of these functions, and enforce using our managed ones? |
We can always do a forced text replacement. Not sure if we want or not. What's your opinion on that? We would need to decide also if we want to do the replacement during writing or on save. |
Given the harm users can cause to themselves/their experience, and the very-close (just safer) equivalence of our wrapped version, I think that would be fine. I guess just replacing when either function name is found without a preceding I think it's ok if we consider custom functionalities like this as a slightly sandboxed version of raw JS, since if users really want to leave our guard-rails they can just modify the actual application. For everybody else it seems desirable to have some safety nets in place, especially to avoid the equivalent of forkbombing yourself or something by just clicking apply or test a few too many times 😅 We're also already allowing things like syntactic sugar for accessing data-lake variables, so I think users already accept things aren't completely normal in there... (speaking of, should this also be checked for in the compound variable definitions?)
During writing it seems annoying for the cursor to jump around unexpectedly, but it also needs to be replaced before the code can be run. I think it should be applied on save for custom actions, and on apply for DIY widgets. |
| setInterval: (callback: () => void, delay?: number) => cockpitTimerManager.createManagedSetInterval(callback, delay), | ||
| setTimeout: (callback: () => void, delay?: number) => cockpitTimerManager.createManagedSetTimeout(callback, delay), |
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.
Would be good if we can match the interface for the real ones - returning ID values that allow user code to clear them if they want to (since that could be relevant to complex functionality).
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.
Agree.
Agree. Will do that. |
Cockpit.0.0.0.2025-12-10.16.12.01.mp4
Fix #1591