Replies: 1 comment 1 reply
-
Currently, If you want a loading indicator during the initial |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Bottom line up top: I'm looking for a way to have a
Shared
value report itisLoading
while fetching values in a subscription.This week's episode on building a
SharedReaderKey
that supports GRDB was terrific. TheFetchKey
rightly focuses on synchronous fetches on the main thread. This is the vast majority of what I need, but there are occasions when I have a long-running operation that needs to be off the main thread. Tweaking the scheduler gets me most of the way, but I can't useisLoading
to give feedback on the load state.The
AnimatedScheduler
is a clever way to inject animations into automatic database observation. To support my async needs, I added a property to the scheduler:Then I added a parameter to the
FetchKey
initializer that configures the scheduler:This correctly moves the work to a background thread while still delivering the data when it's available on the main thread (and animated!). However, I want to show a spinner or something when the data is being loaded. I created a detail view for your GRDBDemo that shows the name and injured status for a single player. I use this key:
I converted the demo app to TCA and declared the player property in a reducer:
Then in the view I want to show a spinner if the data is still loading:
Unfortunately the spinner is never shown. I'm probably misunderstanding the
isLoading
property, but I'd like to be able to set it while a fetch is in progress. There's theValueObservation.handleEvents
method that can hook me into GRDB's change tracking mechanism, but I don't know how to notify theShared
value that a load is in progress. Is this possible?Beta Was this translation helpful? Give feedback.
All reactions