This repository has been archived on 2021-04-30. You can view files and clone it, but cannot push or open issues or pull requests.
blazing-workshop/BlazingPizza.ComponentsLibrary/LocalStorage.cs

18 lines
633 B
C#
Raw Normal View History

2020-12-17 15:52:43 +00:00
using Microsoft.JSInterop;
using System.Threading.Tasks;
namespace BlazingPizza.ComponentsLibrary
{
public static class LocalStorage
{
public static ValueTask<T> GetAsync<T>(IJSRuntime jsRuntime, string key)
=> jsRuntime.InvokeAsync<T>("blazorLocalStorage.get", key);
public static ValueTask SetAsync(IJSRuntime jsRuntime, string key, object value)
=> jsRuntime.InvokeVoidAsync("blazorLocalStorage.set", key, value);
public static ValueTask DeleteAsync(IJSRuntime jsRuntime, string key)
=> jsRuntime.InvokeVoidAsync("blazorLocalStorage.delete", key);
}
}