diff --git a/doc/Learn/Mvux/Advanced/Pagination.md b/doc/Learn/Mvux/Advanced/Pagination.md index c2e00f698a..0c1f57dc34 100644 --- a/doc/Learn/Mvux/Advanced/Pagination.md +++ b/doc/Learn/Mvux/Advanced/Pagination.md @@ -142,7 +142,7 @@ Here's what the app renders like: ## Offset pagination -Offset pagination is controlled via a State that stores the current page index in the Model, and the List-Feed depending on it, using [the `Select` operator](xref:Uno.Extensions.Mvux.Feeds#select-or-selectasync). +Offset pagination is controlled via a State that stores the current page index in the Model, and the List-Feed depending on it, using [the `Select` operator](xref:Uno.Extensions.Reactive.Feed#select). When the user requests a new page, the current page index state is updated, thereby updating the dependent collection List-Feed. Using the example started in [incremental loading above](#incremental-loading), we'll add another method to the service, which will disclose to the View how many items are there in total. Getting a count of items is more efficient than enumerating all entries. This is necessary to identify the total number of pages we have. @@ -188,7 +188,7 @@ public partial record PeopleModel(IPeopleService PeopleService) ``` `PeopleManual` is a Feed that reacts to changes in the `CurrentPage` property and projects the current page data according to its number. -To accomplish this, the [`SelectAsync` operator](xref:Uno.Extensions.Mvux.Feeds#select-or-selectasync) of Feeds is used. +To accomplish this, the [`SelectAsync` operator](xref:Uno.Extensions.Reactive.Feed#selectasync) of Feeds is used. The callback of this operator calls the service's `GetPeopleAsync` with the following arguments: - `pageSize`: As with the [automatic incremental loading](#incremental-loading) example above we're passing the size of each page, except this time we are manually setting the page size to an arbitrary number via the `DefaultPageSize` constant, which is set to `20`. diff --git a/doc/Learn/Mvux/Advanced/Selection.md b/doc/Learn/Mvux/Advanced/Selection.md index aaefa706a3..4e347b4fe8 100644 --- a/doc/Learn/Mvux/Advanced/Selection.md +++ b/doc/Learn/Mvux/Advanced/Selection.md @@ -127,7 +127,7 @@ You can listen and detect selection changes by either creating a feed that proje #### Using the Select operator -Using the example above, we can project the `SelectedPerson` property to project or transform the current `Person`, using the `SelectedPerson`'s [`Where`](xref:Uno.Extensions.Mvux.Feeds#where) and [`Select`](xref:Uno.Extensions.Mvux.Feeds#select) operators. +Using the example above, we can project the `SelectedPerson` property to project or transform the current `Person`, using the `SelectedPerson`'s [`Where`](xref:Uno.Extensions.Reactive.Feed#where) and [`Select`](xref:Uno.Extensions.Reactive.Feed#select) operators. ```csharp public IFeed GreetingSelect => SelectedPerson.Select(person => person == null ? string.Empty : $"Hello {person.FirstName} {person.LastName}!"); @@ -141,7 +141,7 @@ A `TextBlock` can then be added in the UI to display the selected value: #### Using the ForEach operator -Selection can also be propagated manually to a State using the [`ForEach`](xref:Uno.Extensions.Mvux.States#foreach) operator. +Selection can also be propagated manually to a State using the [`ForEach`](xref:Uno.Extensions.Reactive.State#foreach) operator. First, we need to create a State with a default value, which will be used to store the processed value once a selection has occurred. ```csharp diff --git a/doc/Reference/Reactive/feed.md b/doc/Reference/Reactive/feed.md index 41856e30da..65f25de61b 100644 --- a/doc/Reference/Reactive/feed.md +++ b/doc/Reference/Reactive/feed.md @@ -15,7 +15,7 @@ Feeds are typically used to request data from services and expose it in a statel Feeds are stateless and do not provide support for reacting to changes the user makes to the data on the View. The data can only be reloaded and refreshed upon request which is when the underlying task or `IAsyncEnumerable` will be invoked and the data refreshed. In other words, a feed is a read-only representation of the data received from the server. -In contrast to feeds, [states](xref:Uno.Extensions.Mvux.States) (`IState` or `IListState`), as the name suggests, are stateful and keep track of the latest value, as updates are applied. +In contrast to feeds, [states](xref:Uno.Extensions.Reactive.State) (`IState` or `IListState`), as the name suggests, are stateful and keep track of the latest value, as updates are applied. ## Sources: How to create a feed diff --git a/doc/Reference/Reactive/listfeed.md b/doc/Reference/Reactive/listfeed.md index cf0d0fc08f..a98b7a7400 100644 --- a/doc/Reference/Reactive/listfeed.md +++ b/doc/Reference/Reactive/listfeed.md @@ -46,7 +46,7 @@ For example: public IListFeed Names => ListFeed.AsyncEnumerable(service.GetNames); ``` -Pull and push are explained more in the [feeds page](xref:Uno.Extensions.Mvux.Feeds#creation-of-feeds). +Pull and push are explained more in the [feeds page](xref:Uno.Extensions.Reactive.Feed#sources-how-to-create-a-feed). **Create**: Provides custom initialization for a `ListFeed`. diff --git a/doc/Reference/Reactive/state.md b/doc/Reference/Reactive/state.md index 5ce3aab062..ae6fa8a1de 100644 --- a/doc/Reference/Reactive/state.md +++ b/doc/Reference/Reactive/state.md @@ -270,7 +270,7 @@ In this example we'll add the method `IncrementSlider` that gets the current val currentValue <= 99 ? currentValue + 1 : 1; - + await SliderValue.UpdateAsync(updater: incrementValue, ct); } ``` @@ -290,6 +290,8 @@ public async ValueTask SetSliderMiddle(CancellationToken ct = default) ### Subscribing to changes +#### ForEach + The `ForEach` enables executing a callback each time the value of the `IState` is updated. This extension method takes a single parameter which is an async callback that takes two parameters. The first parameter is of type `T?`, where `T` is type of the `IState`, and represents the new value of the state. The second parameter is a `CancellationToken` which can be used to cancel a long running action. @@ -304,12 +306,12 @@ For example: public partial record Model { public IState MyState => ... - + public async ValueTask EnableChangeTracking() { MyState.ForEach(PerformAction); } - + public async ValueTask PerformAction(string item, CancellationToken ct) { ... @@ -324,13 +326,13 @@ Additionally, the `ForEach` method can be set using the Fluent API: { public IState MyState => State.Value(this, "Initial value") .ForEach(PerformAction); - + public async ValueTask PerformAction(string item, CancellationToken ct) { ... } } - + ``` ### Commands @@ -344,9 +346,9 @@ Let's modify the XAML [above](#how-to-bind-the-view-to-a-state) with the followi ... - +