Expand the ImageTask documentation - #920
Merged
Merged
Conversation
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.
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.
Documentation only — no behavior changes, and nothing added to the CHANGELOG.
ImageTaskis 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 privatemakeStream(), 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. Readingtask.eventstwice gives you two streams, and iterating bothprogressandpreviewscreates two subscriptions. Adds a shortfor awaitexample and a note that a stream buffers, so a slow consumer never misses an event.imageandresponse. Both documented onlyImagePipeline.Error.cancelled, which read as if cancellation were the only failure mode. They throw anyImagePipeline.Error— loading, decoding, or processing.responsealso now states that cancelling the awaiting Swift task cancels theImageTaskitself (previously discoverable only fromisCancelled's doc) and that awaiting it repeatedly is safe.progress, awaitimage.cancel(). The public doc gains the outcome (the task fails with.cancelled, streams end with the matching.finishedevent, 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.progressandpreviews. One line each pointing ateventsfor the subscription semantics.To test
swift build— builds clean.Sources/Nuke/ImageTask.swift; the diff is comments only.