Comments (3)
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 QueryRefreshController
from the Environment. This object lets you ask for a refresh. So your case could be covered by something like this (warning! I haven't tested this implementation. I just guess that it will work)
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()
}
}
from graphaello.
But I would be into the idea of adding a kind of RefreshPolicy
modifier to views that are rendering data from GraphQL. Such a RefreshPolicy
could decide in which scenarios to refresh (are there any errors? has a mutation occurred?) and to schedule future refreshes.
let api = MyAPI()
let content = api
.content()
.refreshPolicy(Polling(every: .seconds(20))
from graphaello.
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
from graphaello.
Related Issues (20)
- Make promotional Website HOT 1
- Multi Target Support HOT 1
- Tokamak Support HOT 1
- Swift Package Manager based project support
- Error SwiftSyntax parser library following the tutorial HOT 2
- Error on my endpoint HOT 2
- Handle Updating Apollo HOT 1
- Issue with macro definition HOT 3
- The initializer is not created. HOT 3
- Binding properties are not generated properly in Graphaello.swift HOT 4
- graphaello initialization error HOT 1
- Cannot convert value of type 'GraphQL<Decoder>' to expected argument type 'String'
- Graphaello Buildtime error: Keyword 'repeat' cannot be used as an identifier HOT 2
- graphaello add throws Fatal error HOT 2
- Support for M1 installations of brew HOT 2
- Passthrough Custom Scalars? HOT 4
- Generated view initializers don't camelize default values for enums HOT 2
- codegen not escaping swift keywords HOT 1
- M1 Mac "graphaello is not installed on your machine"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphaello.