Skip to content

Add an article on replacing AsyncImage with LazyImage - #1096

Merged
kean merged 1 commit into
mainfrom
docs/replacing-async-image
Nov 2, 2026
Merged

kean merged 1 commit into
mainfrom
docs/replacing-async-image

Conversation

@kean

@kean kean commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Lands #1095, which merged into feat/environment-pipeline after #1094 had already gone to main, so it never reached main. The commit is unchanged. CI didn't run on #1095 because it was stacked, so this is its first run.

A new article, replacing-async-image, for people who have AsyncImage code, or an agent that writes it, and want LazyImage. #1064 has a mapping table for it among the other libraries; this is the longer walkthrough.

  • The swap for the closure and content:placeholder: forms, and a row for every AsyncImage initializer, including the iOS 27 request: forms, which LazyImage(request:) covers from iOS 16.
  • scale, which lives on ImageRequest and defaults to 1, like AsyncImage.
  • asyncImageURLSession(_:) → imagePipeline(_:), with a DataLoader configuration that carries headers.
  • Where the behavior differs: a nil URL fails with imageRequestMissing, the error is ImagePipeline.Error, and disappearing cancels the load.
  • A LazyImageState.phase extension for code that takes an AsyncImagePhase, so a shared helper doesn't have to be rewritten.

Linked from the SwiftUI article and the topics list, and added to ARTICLE_ORDER so the llms files pick it up at the release (checked by running the generator; the generated files are not committed). Every sample is in ReplacingAsyncImageSnippets.swift, verbatim, and make snippets compiles it. make docs builds with no warnings.

Left out on purpose

Overlap with #1064. Its table says .asyncImageURLSession(_:) maps to .pipeline(_:) on each view, and its "What has no counterpart" section lists the session in the environment. Both are out of date now that #1094 has landed. They are two lines in a file this PR doesn't touch, so I left them.

Covers the swap for each AsyncImage initializer, where the behavior differs
(a missing URL is an error, the error is typed, disappearing cancels the load),
the environment pipeline as the counterpart of asyncImageURLSession(_:), and a
phase helper for code that takes an AsyncImagePhase. Every sample is compiled by
the documentation snippets.
@kean
kean merged commit 311a590 into main Nov 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant