Different ways to initialize a View Provider #11
lookdeceline
announced in
View Provider
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This post guides you through three main ways to initialize a View Provider.
The code snippets take
GroupChannelViewProvider
(orGroupChannelListViewProvider
) forGroupChannelView
(orGroupChannelListView
) as an example, but it works the same for other View Providers as well.version info: SendbirdSwiftUI 1.0.0+
Option 1. Declaring a View Provider as an
@ObservedObject
Option 2. Declaring a View Provider as a
@StateObject
and using theStateObject(wrappedValue:)
init methodinit
method.Option 3. Declaring a View Provider as a
@StateObject
and using the View Provider's.setup()
method in.onAppear()
.setup(...)
method that lets you inject the necessary data into the View Provider after it had already been initialized.Beta Was this translation helpful? Give feedback.
All reactions