Created
July 24, 2024 14:57
-
-
Save Maruchin1/e372c8e27fae1d1eb665ffed43a401ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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