8000 Remove scenario-based RegisterOnRestoring method per review feedback · dotnet/aspnetcore@757ba83 · GitHub
[go: up one dir, main page]

Skip to content

Commit 757ba83

Browse files
Copilotjaviercn
andcommitted
Remove scenario-based RegisterOnRestoring method per review feedback
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
1 parent a8f65ed commit 757ba83

File tree

2 files changed

+10
-27
lines changed

2 files changed

+10
-27
lines changed

src/Components/Components/src/PersistentComponentState.cs

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -162,47 +162,30 @@ internal bool TryTakeFromJson(string key, [DynamicallyAccessedMembers(JsonSerial
162162
}
163163

164164
/// <summary>
165-
/// Registers a callback to be invoked when state is restored for a specific scenario.
166-
/// If state for the scenario is already available, the callback is invoked immediately.
165+
/// Registers a callback to be invoked when state is restored and the filter allows the current scenario.
167166
/// </summary>
168-
/// <param name="scenario">The scenario for which to register the callback.</param>
167+
/// <param name="filter">The filter to determine if the callback should be invoked for a scenario.</param>
169168
/// <param name="callback">The callback to invoke during restoration.</param>
170169
/// <returns>A subscription that can be disposed to unregister the callback.</returns>
171170
public RestoringComponentStateSubscription RegisterOnRestoring(
172-
IPersistentComponentStateScenario scenario,
171+
IPersistentStateFilter filter,
173172
Action callback)
174173
{
175-
ArgumentNullException.ThrowIfNull(scenario);
174+
ArgumentNullException.ThrowIfNull(filter);
176175
ArgumentNullException.ThrowIfNull(callback);
177176

178-
var registration = new RestoreComponentStateRegistration(scenario, callback);
177+
// Create a wrapper scenario that uses the filter
178+
var filterScenario = new FilterWrapperScenario(filter);
179+
var registration = new RestoreComponentStateRegistration(filterScenario, callback);
179180
_restoringCallbacks.Add(registration);
180181

181182
// If we already have a current scenario and it matches, invoke immediately
182-
if (CurrentScenario != null && ShouldInvokeCallback(scenario, CurrentScenario))
183+
if (CurrentScenario != null && ShouldInvokeCallback(filterScenario, CurrentScenario))
183184
{
184185
callback();
185186
}
186187

187-
return new RestoringComponentStateSubscription(_restoringCallbacks, scenario, callback);
188-
}
189-
190-
/// <summary>
191-
/// Registers a callback to be invoked when state is restored and the filter allows the current scenario.
192-
/// </summary>
193-
/// <param name="filter">The filter to determine if the callback should be invoked for a scenario.</param>
194-
/// <param name="callback">The callback to invoke during restoration.</param>
195-
/// <returns>A subscription that can be disposed to unregister the callback.</returns>
196-
public RestoringComponentStateSubscription RegisterOnRestoring(
197-
IPersistentStateFilter filter,
198-
Action callback)
199-
{
200-
ArgumentNullException.ThrowIfNull(filter);
201-
ArgumentNullException.ThrowIfNull(callback);
202-
203-
// Create a wrapper scenario that uses the filter
204-
var filterScenario = new FilterWrapperScenario(filter);
205-
return RegisterOnRestoring(filterScenario, callback);
188+
return new RestoringComponentStateSubscription(_restoringCallbacks, filterScenario, callback);
206189
}
207190

208191
/// <summary>

src/Components/Components/src/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Microsoft.AspNetCore.Components.IPersistentComponentStateScenario.IsRecurring.ge
2626
Microsoft.AspNetCore.Components.IPersistentStateFilter
2727
Microsoft.AspNetCore.Components.IPersistentStateFilter.ShouldRestore(Microsoft.AspNetCore.Components.IPersistentComponentStateScenario! scenario) -> bool
2828
Microsoft.AspNetCore.Components.PersistentComponentState.CurrentScenario.get -> Microsoft.AspNetCore.Components.IPersistentComponentStateScenario?
29-
Microsoft.AspNetCore.Components.PersistentComponentState.RegisterOnRestoring(Microsoft.AspNetCore.Components.IPersistentComponentStateScenario! scenario, System.Action! callback) -> Microsoft.AspNetCore.Components.RestoringComponentStateSubscription
29+
*REMOVED*Microsoft.AspNetCore.Components.PersistentComponentState.RegisterOnRestoring(Microsoft.AspNetCore.Components.IPersistentComponentStateScenario! scenario, System.Action! callback) -> Microsoft.AspNetCore.Components.RestoringComponentStateSubscription
3030
Microsoft.AspNetCore.Components.PersistentComponentState.RegisterOnRestoring(Microsoft.AspNetCore.Components.IPersistentStateFilter! filter, System.Action! callback) -> Microsoft.AspNetCore.Components.RestoringComponentStateSubscription
3131
Microsoft.AspNetCore.Components.RestoringComponentStateSubscription
3232
Microsoft.AspNetCore.Components.RestoringComponentStateSubscription.RestoringComponentStateSubscription() -> void

0 commit comments

Comments
 (0)
0