Skip to content

When to add scheduling option .immediate? #9

Answered by groue
Jasperav asked this question in Q&A
Discussion options

You must be logged in to vote

The scheduling: .immediate option only applies to ValueObservation (documentation). It has the database observation publisher publish its first element immediately, right on subscription.

The publisher is subscribed when a view that contains a @Query property enters the screen, when requested by SwiftUI, from the main thread. When this publisher is .immediate, this allows the view to display database value right from the start (with multiple benefits: see Why @Query?).

But when the database request is slow, this will block the main thread until the ValueObservation has performed its initial fetch. The user may see a noticeable delay before the view appears on screen, and the app won't be …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Jasperav
Comment options

@groue
Comment options

groue Feb 2, 2022
Maintainer

Answer selected by Jasperav
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants