Skip to content

Instantly share code, notes, and snippets.

@Maruchin1
Created July 24, 2024 14:57
Show Gist options
  • Save Maruchin1/e372c8e27fae1d1eb665ffed43a401ca to your computer and use it in GitHub Desktop.
Save Maruchin1/e372c8e27fae1d1eb665ffed43a401ca to your computer and use it in GitHub Desktop.
class UIHostingControllerWrapper<V: View, VM: ViewModel> : UIHostingController<V>, ViewModelStoreOwner {
let viewModelStore = ViewModelStore()
init(rootView: V, viewModel: VM) {
super.init(rootView: rootView)
let key = String(describing: VM.self)
viewModelStore.put(key: key, viewModel: viewModel)
}
deinit {
viewModelStore.clear()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment