79592090

Date: 2025-04-25 08:17:33
Score: 1
Natty:
Report link

Okay, so I found the answer to my own question. But before diving into the solution, I want to share a bit about how I implemented Fluxor in my project.

According to the Fluxor documentation, Fluxor is typically registered like this:

var currentAssembly = typeof(Program).Assembly;
builder.Services.AddFluxor(options => options.ScanAssemblies(currentAssembly));

In my implementation, I wanted to abstract my ApplicationState behind an interface (IApplicationState). So I did the following:

builder.Services
    .AddFluxor(o =>
    {
        o.ScanAssemblies(
            typeof(IApplicationState).Assembly,
            typeof(ApplicationState).Assembly
        );
    })
    .AddSingleton<IApplicationState>(sp => sp.GetRequiredService<ApplicationState>());

Notice that I'm using IApplicationState instead of referencing ApplicationState directly in my components or other services.

This setup works perfectly fine in Blazor WebAssembly. However, for some reason (which I still haven't fully figured out), MAUI Blazor Hybrid doesn't play well with this pattern.

When I removed the interface and registered the state directly like this:

builder.Services
    .AddFluxor(o =>
    {
        o.ScanAssemblies(
            typeof(ApplicationState).Assembly
        );
    });

…it started working correctly in MAUI Blazor Hybrid.

So in short: using an interface for your state class seems to cause issues in MAUI Blazor Hybrid, even though it works fine in Blazor WASM.

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Louis Nong