mrpmorris / Fluxor

Fluxor is a zero boilerplate Flux/Redux library for Microsoft .NET and Blazor.
MIT License
1.26k stars 144 forks source link

Injecting IDispatcher in to RevalidatingServerAuthenticationStateProvider #208

Closed sianmace closed 3 years ago

sianmace commented 3 years ago

Has anyone else injected the IDispatcher in to the a class inheriting from RevalidatingServerAuthenticationStateProvider

I would like to do this, so that i can dispatch a message as i use this to intercept when my access tokens may expire and then refresh them.

If i inject the IDispatcher in the blazor jsut fails to load and i get no errors jsut a white screen, uncommenting that from the constructor makes the app work again. I am injecting other things via DI in to this class without issue?

` public class AuthStateProvider : RevalidatingServerAuthenticationStateProvider { private readonly IHttpClientFactory _httpClientFactory; private readonly IDiscoveryCache _oidcDiscoveryCache; private readonly IConfiguration _configuration; private readonly IState _appState; //private readonly IDispatcher _dispatcher; private readonly ILogger _logger;

    public AuthStateProvider(
        ILoggerFactory loggerFactory,
        //IDispatcher dispatcher,
        IHttpClientFactory httpClientFactory,
        IDiscoveryCache discoveryCache,
        IConfiguration configuration,
        IState<AppState> appState,
        ILogger<AuthStateProvider> logger)
        : base(loggerFactory)
    {
        //_dispatcher = dispatcher;
        _httpClientFactory = httpClientFactory;
        _oidcDiscoveryCache = discoveryCache;
        _configuration = configuration;
        _appState = appState;
        _logger = logger;
    }`

Any thoughts?

sianmace commented 3 years ago

I think this is a blazor issue rather than fluxor. Cant work out how to inject into this revalidation class