dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.04k stars 1.73k forks source link

Add Generic Lifecycle Events #8780

Open dansiegel opened 2 years ago

dansiegel commented 2 years ago

Description

The Application exposes methods to handle OnStart, OnSleep, & OnResume. It is technically possible to hook into these events if multi-targeting and providing native delegates for these Lifecycle Events. Since we already accept that these are platform agnostic events these should exist on the cross platform API for the LifecycleEvents builder.

Public API Changes

This should be generally available on the net6.0 API so that it can be done generically to support any target without the need to explicitly provide a target for an individual platform.

builder.ConfigureLifecycleEvents(lifecycle =>
{
    lifecycle.OnStart(() => {
        // My handler
    });
    lifecycle.OnSleep(() => {
        // My handler
    });
    lifecycle.OnResume(() => {
        // My handler
    });
});

Intended Use-Case

Provide handlers cross platform without the need for libraries like Prism to explicitly provide a compiled target for Android, iOS, Mac, Windows, Tizen, etc.

ghost commented 2 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.