I have begin experimental application with Blazor/Electron.
I have forked the project : https://github.com/SteveSandersonMS/BlazorElectronExperiment.Sample
When the application is closed, It need save the application's state. For this, I think it need handle the close event and save application's state before the final close.
How do handle the close event? Have you other solution?
Blazor live cycle don't have any method ready to be called OnExit
.
An idea may be to implement IDisposable on your component and call saveState
from Dispose
.
If a component implements IDisposable, the Dispose method is called when the component is removed from the UI.
@using System
@implements IDisposable
...
@functions {
public void Dispose()
{
//anti-pattern work around
//liveCycle OnUnload don't exists
save_your_state();
}
}
Disclaimer: This approach is an anti-pattern and it is just a workaround until a more elegant solution be ready.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With