Fix remaining retain cycles, allow coordinators to be weakly referenced and make sure the NavigationStackCoordinator cleans up after itself

This commit is contained in:
Stefan Ceriu
2023-02-02 10:15:31 +02:00
committed by Stefan Ceriu
parent 93997efef9
commit 594f6f85dd
14 changed files with 63 additions and 36 deletions
@@ -27,7 +27,7 @@ class NavigationModule: Identifiable, Hashable {
/// As the NavigationModule is just a wrapper multiple instances of it continuing living is of no consequence
/// https://stackoverflow.com/questions/73885353/found-a-strange-behaviour-of-state-when-combined-to-the-new-navigation-stack/
var coordinator: (any CoordinatorProtocol)?
let dismissalCallback: (() -> Void)?
var dismissalCallback: (() -> Void)?
init(_ coordinator: any CoordinatorProtocol, dismissalCallback: (() -> Void)? = nil) {
self.coordinator = coordinator
@@ -38,6 +38,7 @@ class NavigationModule: Identifiable, Hashable {
coordinator?.stop()
dismissalCallback?()
coordinator = nil
dismissalCallback = nil
}
nonisolated static func == (lhs: NavigationModule, rhs: NavigationModule) -> Bool {