Skip to content

Flow as environmentObject causes memory leak #6

@metallica1375

Description

@metallica1375

Hey I think I found a big issue about the whole concept of using the flow as an environmentObject. when you pass the flow as @EnvironmentObject private var object: FlowProvider the swiftUI holds it in the whole app and none of the view models of any nested screens would get destroyed after the related screen get poped and also for the screens that you hold in the NavigationController stack.
For Example If I start from the home screen and go to the details screen, the view model of the home screen remains alive and also after I pop from the details screen back to the home screen the view model of the details screens remains alive.

public var body: some View {
    flow.present()
      .environmentObject(flow)
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions