How to dynamically set the refresh interval ? #1446
-
Is there a way for a module to dynamically set the refresh interval? I feel kinda stupid but have not been able to simply change the value of the interval in settings. When the widget gets created a timer is created with the initial refresh interval. I can't seem to figure out how to alter that timer's interval. Hopefully someone will tell me "yes, you really are stupid. just set the My use case is a module that has two modes. In one mode it does not need to be refreshed often and in the other mode it needs frequent refreshes. A keyboard event can be used to switch between modes. The key handling works and the module switches modes but the refresh interval does not get changed. Do I need to create two widgets to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
In your config file you should be able to add a per-module |
Beta Was this translation helpful? Give feedback.
-
Take a look at the example here https://wtfutil.com/configuration/common_settings/ |
Beta Was this translation helpful? Give feedback.
-
Thanks for responding to my questions. Perhaps I did not clearly explain what I am trying to do. I can successfully set the It is entirely possible that I am overlooking the obvious here and welcome any knock on the head replies. |
Beta Was this translation helpful? Give feedback.
-
Ah, I get it now. No, unfortunately there isn't a way to dynamically change the refreshInterval after the app launches, because it's all set here https://github.com/wtfutil/wtf/blob/4d526621e61722a5d2b955bba074e6db6422ebdf/app/scheduler.go on start-up. But that's got me thinking that it would be cool to be able to do that with a module. In fact, a module could support:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for cluing me in. The good news is I do not feel as dumb as I thought I might be. I'm just learning the guts of I think we can mark this question as answered and maybe open a feature request for the module methods you propose |
Beta Was this translation helpful? Give feedback.
Ah, I get it now. No, unfortunately there isn't a way to dynamically change the refreshInterval after the app launches, because it's all set here https://github.com/wtfutil/wtf/blob/4d526621e61722a5d2b955bba074e6db6422ebdf/app/scheduler.go on start-up.
But that's got me thinking that it would be cool to be able to do that with a module. In fact, a module could support:
module.PauseRefresh()
module.ResumeRefresh()
module.GetRefreshInterval()
module.SetRefreshInterval(interval)
module.RestoreRefreshInterval()