MAUI & Blazor
.NET MAUI
Section titled “.NET MAUI”Store state in SQLite through Shiny.DocumentDb:
builder.Services.AddShinyActors(actors => actors.UseDocumentDb( new SqliteDatabaseProvider($"Data Source={Path.Combine(FileSystem.AppDataDirectory, "actors.db")}")));The OS can kill a backgrounded app without warning. Either use [AutoSave]
(or actors.UseAutoSave() for every actor), so nothing ever lives only in memory, or flush when the app sleeps:
protected override async void OnSleep() => await actorSystem.DeactivateAllAsync(); // ActorSystem from DI- Reminders while the app is suspended:
UseBackgroundReminders(). - Reminders on time even when the app is dead:
UseReminderNotifications(). - Sharing actors with nearby devices: serve them over HTTP and advertise them over mDNS.
Blazor WebAssembly
Section titled “Blazor WebAssembly”Actors run in the browser too. Store state in IndexedDB through Shiny.DocumentDb. Because the IndexedDB store is
created by the container, call UseDocumentDb() with no arguments:
builder.Services.AddSingleton<IDocumentStore>(sp =>{ var options = new IndexedDbDocumentStoreOptions { DatabaseName = "my-app", JsonSerializerOptions = new JsonSerializerOptions { TypeInfoResolver = ActorDocumentsJsonContext.Default }, UseReflectionFallback = false }; return new IndexedDbDocumentStore(options.MapActorDocuments(), sp);});
builder.Services.AddShinyActors(x => x.UseDocumentDb()); // the IndexedDB store registered aboveReminders fire while the tab is open. A remote client works from the browser as well, as long as the server allows the page’s origin.


