Skip to content

Instantly share code, notes, and snippets.

@fededri
Created January 26, 2022 03:34
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 fededri/c149d3faf6c68b963fcfeccbd31a07b4 to your computer and use it in GitHub Desktop.
Save fededri/c149d3faf6c68b963fcfeccbd31a07b4 to your computer and use it in GitHub Desktop.
struct MoviesListScreenView: View {
@State var state: MoviesState = MoviesState(movies: [], selectedMovie: nil)
let viewModel = MoviesViewModel()
var body: some View {
List() {
ForEach(state.movies, id: \.self) { movie in
MovieView(movie, ...)
}
}
}
}.onAppear(perform: {
viewModel.observeState().collect { self.state = $0 }
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment