kudoleh / iOS-Clean-Architecture-MVVM

Template iOS app using Clean Architecture and MVVM. Includes DIContainer, FlowCoordinator, DTO, Response Caching and one of the views in SwiftUI
https://tech.olx.com/clean-architecture-and-mvvm-on-ios-c9d167d9f5b3
3.91k stars 672 forks source link

Observable is not thread safe #12

Closed harry1064 closed 3 years ago

harry1064 commented 3 years ago

Observable class is not thread-safe. As adding observer from different threads can cause crash.

kudoleh commented 3 years ago

Yes you are right. But it is used only to bind from View controller on viewDidLoad. So all observers are added from main thread always. Sure for other cases we would need to add thread safety. But I there is no such case in this example project. Also if thread safety is needed it can be added easily using serial queue DispatchQueue. But at big companies I worked so far the Observable thread safety was not needed.