Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to communicate between ViewModel and Controller

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.

like image 510
MarkMe Avatar asked Jun 18 '17 12:06

MarkMe


1 Answers

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

like image 79
Soumen Avatar answered Oct 18 '22 10:10

Soumen