-
Notifications
You must be signed in to change notification settings - Fork 107
Open
Description
Was running into an issue with the app I work on where users would occasionally see charts with the incorrect theme (light mode users see dark mode charts after a dark mode user used the app). Did a bunch of digging and realized it was because the global options were shared between all users -- because when using the AddApexCharts() extension method, the object is registered as a singleton service, meaning one instance is created at start-up and re-used for all connections.
I fixed this myself by replacing AddApexCharts with:
builder.Services
.AddScoped(_ => new ApexChartsServiceOptions
{
GlobalOptions = new ApexChartBaseOptions
{
Theme = new()
{
Palette = PaletteType.Palette1,
Mode = Mode.Light
}
}
})
.AddScoped<IApexChartService, ApexChartService>()
.AddHttpClient<ApexChartService>();
Is registering the options as singleton within AddApexCharts an intentional choice? If not, it may be best to change it to scoped; if it is, it might be helpful to future users to at least document this design choice.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels