Skip to content

Support environment insertion of arbitrary ObservableObjects (or other observable types) #279

@MiaKoring

Description

@MiaKoring

SwiftUI allows inserting Observable (@observable) directly into the environment without EnvironmentKeys (ObservableObjects through .environmentObject).
You would access them through @Environment(XYZ.self) and @EnvironmentObject(ZYX.self) respectively.

I believe we should add this ourselves, because its very useful for app state for example.

Once the pr allowing environment insertions through EnvironmentKey is merged, I’m going to work on the implementation. I’m not entirely sure why SwiftUI separates @observable and ObservableObject in this case, both should just be references internally. It might be due to the way they propagate view updates. With SCUIs ObservableObject being compatible with @State I believe we don’t need this separation.

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