Announcing FreshMvvm 1.0.1 Release

No bugs to fix, Yay!

Only some awesome new features, actually really nice extended and very useful features. With such a big take up of FreshMvvm we’ve ramped up the development. As always we take feedback and iterate on it so let us know of anything.

WhenAny

I’ve always loved the WhenAny feature in ReactiveUI and just wanted to have it. Not to mention it’s strongly typed which makes it so much better.

So now your ViewModels (or anything with INotifyPropertyChanged) you can subscribe to the changes of a property using the WhenAny features.

Here’s how you can use it:

public ContactPageModel (IDatabaseService dataService)
{
    _dataService = dataService;

    this.WhenAny(HandleContactChanged, o => o.Contact);
}

void HandleContactChanged(string propertyName)
{
    //handle the property changed, nice
}

Pushing different views

Another awesome feature that we’ve been loving is the ability to push with a different view. This means you can have multiple views for a single ViewModel.

Here’s the signature:

Task PushPageModel<T, TPage> (object data, bool modal = false) where T : FreshBasePageModel where TPage : Page;

So it’s as easy as:

PushPageModel<MyViewModel, MySecondView>();

Clean up after page is Popped

FreshBasePageModel now has a PageWasPopped event, this can be used to cleanup after a page has been Popped.

/// <summary>
/// This event is raise when a page is Popped, this might not be raise everytime a page is Popped. 
/// Note* this might be raised multiple times. 
/// </summary>
public event EventHandler PageWasPopped;

We’ve linked up all the parts within the FreshMvvm project so that the event is always called and always called once, but this might not always be the case if you use a CustomNavigationService and don’t implement correctly.

This is a breaking change on the IFreshNavigationService as it now has a NotifyChildrenPageWasPopped().

If you have a custom navigation service you will need to implement this, here’s a sample of how the builtin master detail service handles it.

public void NotifyChildrenPageWasPopped()
{
    if (Master is NavigationPage)
        ((NavigationPage)Master).NotifyAllChildrenPopped();
    foreach (var page in this.Pages.Values)
    {
        if (page is NavigationPage)
            ((NavigationPage)page).NotifyAllChildrenPopped();
    }
}

As always I love your feedback, please let me know how it do

Thanks

4 Responses

  1. Hi Michael,

    could you please add some more Detaisl to the WhenAny feature? I do not get it completely
    Thanks

    1. The WhenAny is simple, it just calls the method when the property has changed. So in the case below, whenever the Contact property changes the method HandleContactChanged is called.

      public ContactPageModel (IDatabaseService dataService)
      {
      _dataService = dataService;

      this.WhenAny(HandleContactChanged, o => o.Contact);
      }

      void HandleContactChanged(string propertyName)
      {
      //handle the property changed, nice
      }

  2. “The ‘PushPageModel’ does not exist in current context”.

    Could you please be a more specific in announcements and documentation? It isn’t really hard to specify WHICH class exactly has method PushPageModel.

Leave a Reply to Evgeniy Cancel reply