Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,16 @@ public static IServiceCollection AddPaymentProcessorDecoratorExample(this IServi

public static IServiceCollection AddPosAppStateSingletonExample(this IServiceCollection services)
{
services.AddSingleton(_ => PosAppStateDemo.BuildLazy());
services.AddSingleton(_ => Singleton<PosAppState>
.Create(static () => new PosAppState
{
Comment on lines +270 to +272
Config = StoreConfig.Load(),
Pricing = new PricingCache(),
Devices = new DeviceRegistry()
})
.Init(static state => state.Pricing.Prewarm(["SKU-1", "SKU-2", "SKU-3"]))
.Init(static state => state.Devices.ConnectAll())
.Build());
Comment on lines +270 to +279
services.AddSingleton<PosAppStateSingletonExample>(sp => new(sp.GetRequiredService<Singleton<PosAppState>>()));
return services.RegisterExample<PosAppStateSingletonExample>("POS App State Singleton", ExampleIntegrationSurface.LibraryOnly | ExampleIntegrationSurface.DependencyInjection);
}
Expand Down
Loading