Код: Выделить всё
@inject ServiceScopped
@inject IDiposable
information collection
@Code
{
protected override async Task OnInitializedAsync()
{
ServiceScopped.Change += StateHasChanged;
}
private async Task HandleSubmit()
{
await Save();
return;
}
private async Task Save()
{
var ServiceDTO = new ServiceScoppedDTO
{
// I assign the properties entered in the form
}
ServiceScopped.UpdateData(ServiceDTO );
/* I call to open the blank window and generate the table */
await jsRuntime.InvokeVoidAsync("open", "newwindows", "_blank");
}
public void Dispose()
{
ServiceScopped.Change -= StateHasChanged;
}
}
Код: Выделить всё
@inject ServiceScopped
@inject IDiposable
// Here I print my data in an htm table
@Code{
private DataDTO ServiceDTO;
protected override async Task OnInitializedAsync()
{
ServiceScopped.Change += StateHasChanged;
ServiceDTO = ServiceScopped.Data;
}
public void Dispose()
{
ServiceScopped.Change -= StateHasChanged;
}
}
Код: Выделить всё
builder.Services.AddSingleton();
Код: Выделить всё
public class ServiceScopped
{
public DataDTO Data { get; private set; } = new DataDTO();
public event Action? Change;
public void UpdateData(DataDTO newData)
{
Data = newData;
NotifyStateChanged();
}
private void NotifyStateChanged() => Change?.Invoke();
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... ebassembly
Мобильная версия