I am new in development and recently practicing MVVM design pattern. To communicate between the ViewModel & Controller I am using Closure. I know I can use Delegate as well. But is there any convention or reason what particular way I should follow for the communication. I am confused a little bit. Any help will be appreciated.
I was also searching for this answer and I have found this,
Passing a closure from the UI Layer (UIL) to the Business Logic Layer (BLL) would break Separation of Concerns (SOC). The Data you are preparing resides in BLL so essentially you would be saying "hey BLL execute this UIL logic for me". That's an SOC. (Find more here https://en.wikipedia.org/wiki/Separation_of_concerns.)
BLL should only communicate with the UIL via delegate notifications. That way BLL is essentially saying, "Hey UIL, I'm finished executing my logic and here are some data arguments that you can use to manipulate the UI controls as you need to".
So UIL should never ask BLL to execute UI control logic for him. Should only ask BLL to notify him.
Here is the Link, you will get a clearer view.
Usage of MVVM in iOS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With