Skip to content

Instantly share code, notes, and snippets.

@mattmook
Last active September 8, 2021 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattmook/cdef5add34bbb2a72960f1fe5b5673af to your computer and use it in GitHub Desktop.
Save mattmook/cdef5add34bbb2a72960f1fe5b5673af to your computer and use it in GitHub Desktop.
public class PostListViewModelStateObject : ObservableObject {
@Published public private(set) var state: PostListState
init(viewModel: PostListViewModel) {
self.state = viewModel.container.stateFlow.value as! PostListState
(viewModel.container.stateFlow.asPublisher() as AnyPublisher<PostListState, Never>)
.receive(on: RunLoop.main)
.assign(to: &$state)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment