vector-im/element-x-ios/issues/53 - Adopt MainActors, dispatch heavy operations do detached tasks and ensure combine publisher call back on the right queue

This commit is contained in:
Stefan Ceriu
2022-05-25 13:28:19 +03:00
committed by Stefan Ceriu
parent dde7786152
commit f5890b68a2
29 changed files with 100 additions and 90 deletions
@@ -30,6 +30,7 @@ import Combine
/// It provides a nice layer of consistency and also safety. As we are not passing the `ViewModel` to the view directly, shortcuts/hacks
/// can't be made into the `ViewModel`.
@dynamicMemberLookup
@MainActor
class ViewModelContext<ViewState: BindableState, ViewAction>: ObservableObject {
// MARK: - Properties
@@ -70,6 +71,7 @@ class ViewModelContext<ViewState: BindableState, ViewAction>: ObservableObject {
/// a specific portion of state that can be safely bound to.
/// If we decide to add more features to our state management (like doing state processing off the main thread)
/// we can do it in this centralised place.
@MainActor
class StateStoreViewModel<State: BindableState, ViewAction> {
typealias Context = ViewModelContext<State, ViewAction>