Replies: 3 comments 3 replies
-
It is true we don't yet have low-level support to But in general, for this kind of thing we recommend using the more modern struct ContentView : View {
var body: some View {
TabView {
TabView1()
TabView2()
TabView3()
}
.task(priority: .background) {
while !Task.isCancelled {
do {
try await Task.sleep(nanoseconds: 1_000_000_000) // 1 second
logger.log("executing periodic task at: \(Date.now)")
try await viewModel.performUpdates() // or whatever…
} catch {
logger.error("error executing periodic task: \(error)")
}
}
}
}
} Please let us know if that is sufficient for your needs. If not, I'm sure we can put together a solution. |
Beta Was this translation helpful? Give feedback.
-
I think I might be able to use this as a workaround of sorts, but the framework I'm creating (a web service API client that keeps track of the last time updates occurred and periodically performs them as necessary) isn't inherently SwiftUI-specific. Ideally it could handle the periodic checks itself. I think I could probably use the above as a workaround to get this functional for my needs, though, so as long as full Timer support is on the roadmap somewhere there's no need to develop a prioritized solution for me. My first intended use will tie into SwiftUI so I think I can use the above method above kick off its do-I-need-to-do-an-update logic. I imagine others will run across this limitation, but I also know that you still have a lot on your plate. Thanks! |
Beta Was this translation helpful? Give feedback.
-
SkipFoundation now includes basic Timer support. SkipModel and SkipUI have also been updated to allow you to use Timer.publish(...).autoconnect() and View.onReceive(Publisher) Let us know if you run into any problems! |
Beta Was this translation helpful? Give feedback.
-
If the
Unresolved reference: Timer
errors are anything to go by, it doesn't look like Skip currently supportsTimer
in any of its various forms.It would be helpful to see this implemented at some point. There are an awful lot of scenarios that really depend upon having the ability to run code on a regular schedule.
Beta Was this translation helpful? Give feedback.
All reactions