-
Notifications
You must be signed in to change notification settings - Fork 18
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
Polling #32
Comments
Yes! There is a way to refresh the content. However, I haven't built in any functionality like refreshing every N seconds. You can get a struct ContentView: View {
@Environment(\.queryRefreshController)
var refreshController
@State
private var timer: Timer?
var body: some View {
VStack {
....
}
.onAppear {
DispatchQueue.main.async {
self.timer = Timer.scheduledTimer(withTimeInterval: 20, repeats: true) { _ in
self.refreshController?.refresh()
}
}
}
.onDisappear {
self.timer?.invalidate()
}
}
|
But I would be into the idea of adding a kind of let api = MyAPI()
let content = api
.content()
.refreshPolicy(Polling(every: .seconds(20)) |
Yes, that’s sounds really useful! Especially refreshing on mutations of a given field is super good, since that means I can subscribe to updates whenever they happen anywhere in the app 😍 |
I was looking at this, and was wondering if there currently is a way to poll a query every N seconds? (E.g. if I display a set of comments, I might want to refresh the view every few seconds such that people are always up-to-date.)
The text was updated successfully, but these errors were encountered: