Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Prism app on initialized #20

Merged
merged 5 commits into from
May 7, 2022
Merged

Prism app on initialized #20

merged 5 commits into from
May 7, 2022

Conversation

dansiegel
Copy link
Member

Description

The App Initialization has been completely refactored. We no longer strictly follow the MAUI paradigm. PrismApplication is now optional with better Legacy support with a refactored approach that invokes the normal OnInitialized that every Prism.Forms application uses.

// Required ONLY if you do not use the OnAppStart extension on the PrismAppBuilder
public partial class App : PrismApplication
{
    protected override async void OnInitialized()
    {
        await NavigationService.NavigateAysnc("SomeUri");
    }
}

With this PR you can now choose to use EITHER a PrismApplication or simply inherit from the MAUI Application. The Builder has been updated to support a better workflow...

return MauiApp.CreateBuilder()
    .UsePrismApp<App>()
    .RegisterTypes(containerRegistry => {

    })
    .OnInitialized(() => {
        // startup initializations that do not require the container...
    });
    .OnInitialized(container => {
        // startup initializations that require the container to resolve registered services
        // Note that this will be fired prior to the modules loading
    })
    .OnAppStart(async navigationService => await navigationService.NavigateAsync("SomeUri"))
    .ConfigureFonts(fonts => fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"))
    .Build();

NOTES

When using OnInitialized extensions in the PrismAppBuilder, these are triggered prior to the Modules being loaded as they are loaded internally through this process and it is only after the initializations that the ModuleManager is run.

When using the OnAppStart extension of the PrismAppBuilder, this returns the MauiAppBuilder eliminating the need to reference it as a property to get back to continuing to build the MauiApp.

@dansiegel dansiegel added the enhancement New feature or request label May 7, 2022
@dansiegel dansiegel merged commit 6627713 into master May 7, 2022
@dansiegel dansiegel deleted the PrismApp-OnInitialized branch May 7, 2022 17:37
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant