Static Vision Models / Presentation Models

Would it be wrong to do all of my static View Models / Presentation Models classes so that if any other View Presenter wanted to change a presentation model other than its own, could it easily get a link to it?

If this is the wrong approach, how would you achieve it?

+3
source share
2 answers

Static ViewModels sounds like a terrible idea (I consider static evil as a general principle). This means that you cannot have more than one instance of ViewModel. I can come up with many examples of the user interface where there are several instances of the same type of View, but this is not possible for static ViewModels.

If you want to enable data exchange between views, Publish / Sign (events) is much better.

, ViewModels/Presentaion, . sevaral Views, , Domain Object , ViewModel, , .

0

, Singleton. , , - .

, concurrency, 1 - . .

, Factory. , , . concurrency ( ) .

+1

Source: https://habr.com/ru/post/1727869/


All Articles