You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/blazor/components/cascading-values-and-parameters.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,7 +75,7 @@ The following `Daleks` component displays the cascaded values.
75
75
76
76
:::moniker range=">= aspnetcore-8.0"
77
77
78
-
In the following example, `Dalek` is registered as a cascading value using [`CascadingValueSource<T>`](xref:Microsoft.AspNetCore.Components.CascadingValueSource%601), where `<T>` is the type. The `isFixed` flag indicates whether the value is fixed. If false, all recipients are subscribed for update notifications. Subscriptions create overhead and reduce performance, so set `isFixed` to `true` if the value doesn't change.
78
+
In the following example, `Dalek` is registered as a cascading value using [`CascadingValueSource<T>`](xref:Microsoft.AspNetCore.Components.CascadingValueSource%601), where `<T>` is the type. The `isFixed` flag indicates whether the value is fixed. If `false`, all recipients are subscribed for update notifications. Subscriptions create overhead and reduce performance, so set `isFixed` to `true` if the value doesn't change.
79
79
80
80
```csharp
81
81
builder.Services.AddCascadingValue(sp=>
@@ -131,7 +131,7 @@ public class NotifyingDalek : INotifyPropertyChanged
@@ -184,7 +184,7 @@ public static class CascadingStateServiceCollectionExtensions
184
184
185
185
publicvoidDispose()
186
186
{
187
-
value.PropertyChanged-=HandlePropertyChanged;
187
+
state.PropertyChanged-=HandlePropertyChanged;
188
188
}
189
189
}
190
190
}
@@ -252,7 +252,7 @@ The following component is used to demonstrate how changing the value of `Notify
252
252
{
253
253
if (Dalek is not null)
254
254
{
255
-
await Dalek.SetUnitsToOneThousand();
255
+
await Dalek.SetUnitsToOneThousandAsync();
256
256
}
257
257
}
258
258
}
@@ -278,7 +278,7 @@ To demonstrate multiple subscriber notifications, the following `DaleksMain` com
278
278
279
279
Because the <xref:Microsoft.AspNetCore.Components.CascadingValueSource%601>'s type in this example (`NotifyingDalek`) is a class type, you can meet virtually any state management feature specification requirement. However, subscriptions create overhead and reduce performance, so benchmark the performance of this approach in your app and compare it to other [state management approaches](xref:blazor/state-management) before adopting it in a production app with constrained processing and memory resources.
280
280
281
-
Any change in state (any property value change of the class) causes all subscribed components to rerender, regardless of which part of the state that they use. **Avoid creating a single large class representing the entire global application state.** Instead, create granular classes and cascade them separately with specific subscriptions to cascading parameters, ensuring that only components subscribed to a specific portion of the application state are affected by changes.
281
+
Any change in state (any property value change of the class) causes all subscribed components to rerender, regardless of which part of the state they use. **Avoid creating a single large class representing the entire global application state.** Instead, create granular classes and cascade them separately with specific subscriptions to cascading parameters, ensuring that only components subscribed to a specific portion of the application state are affected by changes.
0 commit comments