Thank for such great, simple but not trivial, examples!
@aleksandrzinovev429Ай бұрын
You have a talent for explaining complex concepts clearly
@DonnyWalsdevАй бұрын
Thank you!
@indiekiduk8 ай бұрын
I think makeStream is an anti-pattern because I ran into issues when using like cancellation not working. Once I redesigned my async code and made AsyncStream own the object that yields values all my problems were solved!
@DonnyWalsdev8 ай бұрын
Any chance you have a gist that would demonstrate the issues you've had? The tests I ran involved moving from the older AsyncStream init to makeStream and I didn't see these issues.
@indiekiduk8 ай бұрын
@@DonnyWalsdev ok I'm trying to work on that. I noticed you had onTermination = { [weak self] that must have been to work around the retain cycle issue.
@indiekiduk8 ай бұрын
I've been investigating this all day and I think makeStream is fine. By using a weak var in the parent object and using onTerminate to capture a strong reference to the stream's object I can make cancellation deinit the stream's object properly. My test harness has a task group with 2 tasks that call the same stream property on its containing object (to make sure the first stream is cancelled). I can only have one stream working at a time despite the object's stream property being a computed var that returns a new stream, so I wanted it to also cancel a previous stream.