8000 ViewFactory should be @MainActor constrained · Issue #722 · GetStream/stream-chat-swiftui · GitHub
[go: up one dir, main page]

Skip to content
ViewFactory should be @MainActor constrained #722
@swizzlr

Description

@swizzlr

What are you trying to achieve?

I have views that depend on MainActor isolated view models. In order to initialize my views I need to retrieve these MainActor isolated dependencies that are retrieved via "@Inject" in the viewfactory. Since the viewfactory methods are nonisolated, I'm not able to access these - and if I annotate the methods as @mainactor, they do not satisfy the protocol requirements.

If possible, how can you achieve this currently?

Maybe I could try injecting them directly into the views?

What would be the better way?

Since SwiftUI Views are MainActor isolated to begin with, and the ViewFactory is invoked from Views in a MainActor isolated context, it seems reasonable to constrain the ViewFactory to MainActor

GetStream Environment

GetStream Chat version: 4.61
GetStream Chat frameworks: StreamChat, StreamChatSwiftUI
iOS version: any
Swift version: 6
Xcode version: 16.2
Device: any

Additional context

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0