Skip to content

Expand the ImageTask documentation - #920

Merged
kean merged 1 commit into
mainfrom
docs/image-task
Aug 16, 2026
Merged

Expand the ImageTask documentation#920
kean merged 1 commit into
mainfrom
docs/image-task

Conversation

@kean

@kean kean commented Aug 16, 2026

Copy link
Copy Markdown
Owner

Documentation only — no behavior changes, and nothing added to the CHANGELOG.

ImageTask is the type users hold the most, and its most important caveats were either missing or written where DocC never publishes them.

  • events. The explanation of how subscription works lived on the private makeStream(), so it was invisible to anyone reading the docs. It now sits on the public property, along with the part that wasn't written down anywhere: every access creates a new independent stream. Reading task.events twice gives you two streams, and iterating both progress and previews creates two subscriptions. Adds a short for await example and a note that a stream buffers, so a slow consumer never misses an event.
  • image and response. Both documented only ImagePipeline.Error.cancelled, which read as if cancellation were the only failure mode. They throw any ImagePipeline.Error — loading, decoding, or processing. response also now states that cancelling the awaiting Swift task cancels the ImageTask itself (previously discoverable only from isCancelled's doc) and that awaiting it repeatedly is safe.
  • Class-level doc. Adds a usage example: create the task, observe progress, await image.
  • cancel(). The public doc gains the outcome (the task fails with .cancelled, streams end with the matching .finished event, and calling it twice or after the task finished does nothing). Inside, // Make sure it gets called once (expensive) never said what was expensive; it now names the actor hop and the teardown it triggers.
  • progress and previews. One line each pointing at events for the subscription semantics.

To test

  1. swift build — builds clean.
  2. Read through Sources/Nuke/ImageTask.swift; the diff is comments only.

Move the caveats about the event stream from the private `makeStream()`
to the public `events` property so they show up in DocC, spell out that
`image` and `response` throw any `ImagePipeline.Error` rather than only
`cancelled`, and add a usage example to the class-level doc.
@kean
kean merged commit 2ea9301 into main Aug 16, 2026
5 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