Skip to content

Commit fcfdf18

Browse files
authored
Update persistent state examples (dotnet#225)
1 parent 1598612 commit fcfdf18

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

8.0/BlazorSample_BlazorWebApp/Components/Pages/PrerenderedCounter2.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
ApplicationState.RegisterOnPersisting(PersistCount);
2222

2323
if (!ApplicationState.TryTakeFromJson<int>(
24-
"count", out var restoredCount))
24+
nameof(currentCount), out var restoredCount))
2525
{
2626
currentCount = Random.Shared.Next(100);
2727
Logger.LogInformation("currentCount set to {Count}", currentCount);
@@ -35,7 +35,7 @@
3535

3636
private Task PersistCount()
3737
{
38-
ApplicationState.PersistAsJson("count", currentCount);
38+
ApplicationState.PersistAsJson(nameof(currentCount), currentCount);
3939

4040
return Task.CompletedTask;
4141
}

8.0/BlazorWebAppOidc/BlazorWebAppOidc.Client/Pages/Weather.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ else
4949
{
5050
persistingSubscription = ApplicationState.RegisterOnPersisting(PersistData);
5151

52-
if (!ApplicationState.TryTakeFromJson<IEnumerable<WeatherForecast>>("data", out var restoredData))
52+
if (!ApplicationState.TryTakeFromJson<IEnumerable<WeatherForecast>>(nameof(forecasts), out var restoredData))
5353
{
5454
forecasts = await WeatherForecaster.GetWeatherForecastAsync();
5555
}
@@ -61,7 +61,7 @@ else
6161

6262
private Task PersistData()
6363
{
64-
ApplicationState.PersistAsJson("data", forecasts);
64+
ApplicationState.PersistAsJson(nameof(forecasts), forecasts);
6565

6666
return Task.CompletedTask;
6767
}

0 commit comments

Comments
 (0)