Refactoring Data Passing Methods in BuildIt.Lifecycle

In my earlier post, Passing Data Between States with BuildIt.Lifecycle, the state declarations for the primary application region started to look really messy. As promised I’ve tidied up the extension helper methods, making it much easier to define delegates that are invoked when changing to and from a state. The updated state declartion now looks like:

    .StateWithViewModel<AppStates, MainViewModel>(AppStates.Home)
        .OnCompleteWithData< AppStates, MainViewModel,MainCompletion,string>(MainCompletion.About,null)
        .WhenChangedTo(async vm => await vm.LoadData())
    .StateWithViewModel<AppStates, SettingsViewModel>(AppStates.Settings)
        .WhenChangedToWithData<AppStates, SettingsViewModel, string>((vm, d) => vm.SettingsTitle = d)
    .StateWithViewModel<AppStates, AboutViewModel>(AppStates.About)
        .WhenChangedToWithData<AppStates, AboutViewModel, string>((vm, d) => vm.AboutTitle = d)

Note that if you’re attempting to use these updates they haven’t yet made their way into the NuGet packages. I’ll endeavour to update these packages later this week. In the meantime I’d recommend downloading the source from the BuildIt repository on GitHub.

Leave a comment