-
-
Notifications
You must be signed in to change notification settings - Fork 119
Open
Labels
BugSomething isn't workingSomething isn't workingTriageIssue needs to be triagedIssue needs to be triaged
Description
Describe the bug
IJSInProcessRuntime not available is thrown when trying to read from local storage.
Developing a cart where I use OnChange event to update the cart item counter. This have worked before with older .NET version.
To Reproduce
@inject Blazored.LocalStorage.ISyncLocalStorageService LocalStorage
@implements IDisposable
....
private int GetCartItemCount()
{
var cart = LocalStorage.GetItem<List<CartItemDto>>("b_cart"); // ERROR: IJSInProcessRuntime not available
return cart != null ? cart.Count : 0;
}
// subscribe to the cart changes event
protected override void OnInitialized()
{
CartService.OnChange += StateHasChanged;
}
public void Dispose()
{
CartService.OnChange -= StateHasChanged;
}
After adding items to the cart I invoke the OnChange event.
public event Action OnChange;
....
await _localStorage.SetItemAsync("b_cart", cart);
OnChange.Invoke();
Expected behavior
Counter should be updated with number of items in cart.
Hosting Model (is this issue happening with a certain hosting model?):
- Blazor WebAssembly .NET 9
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't workingTriageIssue needs to be triagedIssue needs to be triaged