Skip to main content
net6.0net6.0-android31.0net6.0-ios16.1net6.0-maccatalyst16.1net6.0-windows10.0.19041

Akka.Hosting support for .NET Maui applications. Works on all supported Maui platforms.

Published
Jul 6, 2023
3y ago
Total Downloads
2.8K
2,820

Install

dotnet add package Akka.Hosting.Maui --version 1.5.8
ProductVersions
.NET
net6.0net6.0-android31.0net6.0-ios16.1net6.0-maccatalyst16.1net6.0-windows10.0.19041

README

Akka.Hosting.Maui

HOCON-less configuration, application lifecycle management, ActorSystem startup, and actor instantiation for Akka.NET. This is an Akka.Hosting adapter for .NET Maui applications.

The reason this exists in the first place is because Microsoft.Extensions.Hosting aren't supported on .NET Maui and there are no plans to support it. We've adapted Akka.Hosting to run using a Maui IMauiInitializeService instead an IHostedService behind the scenes - and this should make it trivially easy to use Akka.Hosting's 'ActorRegistry' to inject actors into your UI elements and background services.

Installation

First, you need to install the Akka.Hosting.Maui package into your Maui application:

dotnet add package Akka.Hosting.Maui

Next, inside your MauiProgram.cs (or equivalent) call the AddAkkaMaui method:

using Akka.Hosting.Maui;
using Akka.Hosting.MauiSample;
using Microsoft.Extensions.Logging;

namespace Akka.Hosting.MauiDemo;

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
            });

#if DEBUG
        builder.Logging.AddDebug();
#endif
        
        builder.Services
            .AddAkkaMaui("TestSys", config =>
            {
                config.WithActors((system, registry) =>
                {
                    var echo = system.ActorOf(ClickActor.Props);
                    registry.Register<ClickActor>(echo);
                });
            })
            .AddTransient<MainPage>();

        return builder.Build();
    }
}

And from there, you should be able to use any of the other Akka.Hosting methods to configure your ActorSystem and your actors!

Changes from Previous Version

v1.5.6.1v1.5.8
Added Frameworks
net6.0net6.0-android31.0net6.0-ios16.1net6.0-maccatalyst16.1net6.0-windows10.0.19041
Removed Frameworks
net7.0net7.0-android33.0net7.0-ios16.1net7.0-maccatalyst16.1net7.0-windows10.0.19041
Added Dependencies
Akka.Hosting(net6.0)
Akka.Hosting(net6.0-android31.0)
Akka.Hosting(net6.0-ios16.1)
Akka.Hosting(net6.0-maccatalyst16.1)
Akka.Hosting(net6.0-windows10.0.19041)
Removed Dependencies
Akka.Hosting(net7.0)
Akka.Hosting(net7.0-android33.0)
Akka.Hosting(net7.0-ios16.1)
Akka.Hosting(net7.0-maccatalyst16.1)
Akka.Hosting(net7.0-windows10.0.19041)

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

Compatibility metadata lists 5 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.