[Swift] Add preload state observability - #445
Merged
Merged
Conversation
Contributor
Author
markmur
force-pushed
the
preloading-impl
branch
2 times, most recently
from
July 13, 2026 20:48
7364e75 to
03e7678
Compare
This was referenced Jul 13, 2026
tiagocandido
approved these changes
Jul 14, 2026
markmur
force-pushed
the
preloading-impl
branch
5 times, most recently
from
July 15, 2026 16:01
71863e5 to
2557311
Compare
Install this buildOpen Tophat, select your target device, then click Install. Links open on the Mac running Tophat.
Checkout Kit E2E results
|
- Add terminate(with:disconnect:) to unify invalidate + state transition - Emit terminal state (.expired/.idle) on cache miss/stale in view(for:) - Ignore cancelled provisional navigations (redirects/policy cancels) - Clear cache before notifying so re-entrant preload survives expiry
kieran-osgood-shopify
approved these changes
Jul 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds observable lifecycle state to preloaded checkouts on iOS.
preload(checkout:)returns a retainedCheckoutPreloadhandle that exposes the currentstateand emits transitions —.loading → .ready → .expired,.failed(reason:)for HTTP, navigation, and keep-alive failures, and.idleon manual invalidation. State is driven from a singletransitionchoke point in the preload cache and broadcast to a weak observer, so consumers can drive spinners or fall back to a fresh preload when a warm entry lapses.CheckoutPreloadis anObservableObject, so you can observe it with a closure, Combine's$state, or directly in SwiftUI.Observe with a closure
onStateChangefires immediately with the current state on assignment, then on every transition.Read the current state synchronously
Observe in SwiftUI
Fire-and-forget warming