I don't think this was the best of demos... but we will come back and use the Mvvmcross Messenger a **lot** in future samples - http://nuget.org/packages/MvvmCross.HotTuna.Plugin.Messenger/ - so I'll try to explain it again better then :)
The code is in: https://github.com/slodge/NPlus1DaysOfMvvmCross/tree/master/N-09-Location%20And%20Message
Previously in N+1:
- N=0 - a first application - http://slodge.blogspot.co.uk/2013/04/n0-first-mvvmcross-application-n1-days.html
- N=1 - tip calc - including the Android Designer and using IoC -http://slodge.blogspot.com/2013/04/n1-tipcalc-second-example-adding-ioc.html
- N=2 - Kittens - lists and tables - N=2: Lists and Kittens (N+1 days of MvvmCross)
- N=3 - Kitten Cells on iPhone - http://slodge.blogspot.co.uk/2013/04/n3-kitten-cells-on-iphone-n1-days-of.html
- N=4 - ValueConverters - http://slodge.blogspot.co.uk/2013/04/n4-valueconverters-n1-days-of-mvvmcross.html
- N=5 - ICommand and Multiple Pages - http://slodge.blogspot.co.uk/2013/04/n5-some-first-icommands-and-multiple.html
- N=6 - Books over the Network - http://slodge.blogspot.co.uk/2013/05/n6-books-over-network-n1-days-of.html
- N=7 - Books++ - a little UI refinement - http://slodge.blogspot.co.uk/2013/05/n7-adding-some-refinements-to-books-n1.html
- N=8 - Location, Location, Location - http://slodge.blogspot.co.uk/2013/05/n8-location-location-location-n1-days.html
Can you perhaps elaborate on the benefit of using the Messenger as compared with ordinary events?
ReplyDeleteI think best to ask that question on stackoverflow with tags 'messenger', 'mvvm' and 'mvvmcross' - there should be plenty of people with plenty of interesting and different opinions :)
DeleteOh, and thanks for sharing, I've enjoyed the series immensely :).
ReplyDeleteYou mentioning weak references etc. made me wonder about the lifecycle of the View Models themselves. Perhaps this is just my lack of experience with MVVM (I'm really a web, server side developer) but do the View Models get released as the application is navigated between View Models or are they kept around? I can see issues with both approaches.
ReplyDeleteViewModels should live as long as their views do - that's it. But how long the views live is determined by each OS... There's some information on a topic similar to this in http://stackoverflow.com/questions/16299639/detecting-whether-a-viewmodels-associated-view-is-showing-not-showing - if you want more than that, then please ask a new question on SO. Thanks :)
DeleteThe question just popped into my head as I was watching the video, your reply was just the right level, thanks. Great series by the way.
Delete