Introducing swift-dependencies, a dependency injection library inspired by SwiftUI's "environment"

I think this issue has less to do with the actual method of dependency injection and more about ‘never ending’ signals.

In Swift there was a design choice to capture self implicitly in a Task. Assuming that most tasks are short lived. This is probably true for many cases, but causes surprises in the remaining cases. :blush:

That, coupled with a never ending signal gives a retain cycle.

But it’s actually also a retain cycle even if the signal ends. As long as the signal outlives ‘self’, you have a retain cycle for a while.

I’d love to see a solution to this pattern in Swift - that doesn’t require having to remember capturing self weakly inside the Task.

1 Like