Plugins in ViewModel

2019-08-30 07:31发布

问题:

I'm new on MvvmCross and I want to use my plugin in my Model/ViewMode. I use the v3.

In some example I see IMvxServiceConsumer and GetService, but I guess that is the annotation for vNext but it seems to be different in the v3.

So, how can I do that?

Thanks

回答1:

IMvxServiceConsumer<T> and GetService<T> were replaced with Mvx.Resolve<T> in v3.

Further, v3 provides constructor injection of dependencies - see http://slodge.blogspot.co.uk/2013/03/v3-new-viewmodel-lifecycle.html for information about how this decision was reached.

For plugins, N=8 in the tutorial series gives a quick and easy introduction to using the Location plugin. For more info see:

  • blog - http://slodge.blogspot.co.uk/2013/05/n8-location-location-location-n1-days.html
  • youtube - https://www.youtube.com/watch?v=AomjbED9AzM&list=PLR6WI6W1JdeYSXLbm58jwAKYT7RQR31-W&index=10

If you want to write a new plugin, then :

  • the up-to-date sample is https://github.com/slodge/MvvmCross-Tutorials/tree/master/GoodVibrations
  • there are some notes on this sample in https://speakerdeck.com/cirrious/plugins-in-mvvmcross