@implements IDisposable

@using RobotNet.WebApp.Robots.Components.Monitoring.Element

@foreach (var robot in Models)
{
    <Robot Model="@robot" ShowName="@ShowName" />
}


@code {
    [Parameter, EditorRequired]
    public MapRobotModel Models { get; set; } = null!;

    [Parameter]
    public bool ShowName { get; set; }

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        await base.OnAfterRenderAsync(firstRender); 
        if (!firstRender) return;
        Models.Changed += StateHasChanged;
    }

    public void Dispose()
    {
        Models.Changed -= StateHasChanged;
        GC.SuppressFinalize(this);
    }
}
