mvvm - MvvmCross: Application wide view model? -
i loving mvvmcross far, new mvvm technique. mvvm seems center around view , viewmodel , navigating between them. however, application-wide model items? maybe application has mode can in affects views , viewmodel behavior. seems applicationmodel or applicationviewmodel. or maybe use app class store application wide stuff? recommended practice concept? if using app class idea, assume there easy way hold of reference app instance anywhere? haven't looked yet.
a viewmodel
model view - that's current mvvmcross focus sits.
for application wide behaviour, think it's best consider 1 use case @ time.
the example you've provided is:
maybe application has mode can in affects views , viewmodel behavior.
there's not detail here, type of thing might perhaps:
- place
mode
insidesingleton
service - would use messenger send
modechangedmessage
s whenmode
changed - would provide service , messenger relevant viewmodels using constructor injection
- the viewmodels can subscribe
modechangedmessage
on messenger - would perhaps use inheritance in viewmodels share code between them (ie they'd inherit
baseviewmodel
class)
there of course other ways this, that's 1 suggestion
if there's other application wide use case you'd ask about, please ask question - please include more detail - eg perhaps provide pseudo-code want share. find real use cases easier work out - abstract ideas harder talk about.
if helps:
- there's introduction services , constructor injection in n=2 on http://mvvmcross.wordpress.com
- there's introduction messenger on n=9 in http://mvvmcross.wordpress.com
Comments
Post a Comment