Skip to content

Commit 061821c

Browse files
committed
api [nfc]: Tighten comments about streaming JSON-plus-UTF-8 decoder
This is a bit off the main line of what a reader of this method will mostly want to know about (as the method is mainly about semantics, not performance optimization). So keep the comments fairly short, to avoid distracting the reader's focus from the rest of the method.
1 parent a792a89 commit 061821c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/api/core.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,9 @@ class ApiConnection {
147147
final int httpStatus = response.statusCode;
148148
Map<String, dynamic>? json;
149149
try {
150-
// Pass the response stream through the `jsonUtf8Decoder` transformer,
151-
// allowing decoding to start as soon as the response stream emits data
152-
// chunks.
150+
// The stream-oriented `bind` method allows decoding to happen in chunks
151+
// while the response is still being downloaded, improving latency.
153152
final jsonStream = jsonUtf8Decoder.bind(response.stream);
154-
155-
// Actually start listening to the response byte stream and wait for
156-
// decoding to finish.
157153
json = await jsonStream.single as Map<String, dynamic>?;
158154
} catch (e) {
159155
// We'll throw something below, seeing `json` is null.

0 commit comments

Comments
 (0)