I'm slightly confused as to what I'm doing wrong, I'm using Blazor and I have a working setup with another state but when adding this new "SessionsState" I get a DI issue:
Unable to resolve service for type 'Fluxor.IFeature1[System.Collections.Generic.IEnumerable1[Clarity.Web.Data.Session]]' while attempting to activate 'Fluxor.State1[System.Collections.Generic.IEnumerable1[Clarity.Web.Data.Session]]'.
[FeatureState]
public class SessionsState
{
public IEnumerable<Session> Sessions { get; } = new List<Session>();
[Inject]
public IDispatcher Dispatcher { get; set; }
private SessionsState()
{
}
public SessionsState(IEnumerable<Session> sessions)
{
Sessions = sessions;
}
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public partial class SessionDetailBase : FluxorComponent
{
[Parameter]
public int id { get; set; }
[Inject] protected IState<IEnumerable<Session>> SessionState { get; private set; }
protected Session session;
protected int Index = -1; //default value cannot be 0 -> first selectedindex is 0.
protected double[] inputData;
protected string[] inputLabels;
protected override void OnInitialized()
{
base.OnInitialized();
this.session = this.SessionState.Value.FirstOrDefault(x => x.SessionId == id);
this.inputData = session.StateTimingEntries.GroupBy(x => x.StatusType).Select(x => (double)x.Sum(y => y.TimeInStateSeconds)).ToArray();
this.inputLabels = session.StateTimingEntries.GroupBy(x => x.StatusType).Select(x => x.Key.GetEnumDescription()).ToArray();
StateHasChanged();
}
}```
Microsoft DI will always use the greediest constructor, so is trying to use your feature constructor that expects an IEnumerable<Session> which you don't have registered with DI.
I'm slightly confused as to what I'm doing wrong, I'm using Blazor and I have a working setup with another state but when adding this new "SessionsState" I get a DI issue:
Unable to resolve service for type 'Fluxor.IFeature
1[System.Collections.Generic.IEnumerable1[Clarity.Web.Data.Session]]' while attempting to activate 'Fluxor.State
1[System.Collections.Generic.IEnumerable1[Clarity.Web.Data.Session]]'.