Skip to content

Commit cb92e2c

Browse files
committed
improve workaround
1 parent a9b30e8 commit cb92e2c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

bk1ch05zp05MakeYourOwnAsyncStream/MakeYourOwnAsyncStream/ViewController.swift

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ class TextFieldSelectionChangeStreamer: NSObject, UITextFieldDelegate {
1010
self.values = AsyncStream { continuation in
1111
myContinuation = continuation
1212
// I also tried to set the `onTermination` handler but couldn't; filed a bug
13-
// ooo, Tyler Prevost has a workaround:
14-
continuation.onTermination = { term in
13+
// ooo, Tyler Prevost has a workaround (improved by Doug Gregor at bugs.swift.org):
14+
// https://stackoverflow.com/questions/69047723/cant-set-asyncstream-ontermination-handler
15+
continuation.onTermination = { @Sendable term in
1516
print("terminated!")
16-
} as (@Sendable (AsyncStream<UITextField>.Continuation.Termination) -> Void)
17+
}
1718
// but not fixed in RC
1819
}
1920
super.init()

0 commit comments

Comments
 (0)