Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: MVUX Feedback #1601

Merged
merged 8 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added doc/Overview/Mvux/Assets/Mvux.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/Overview/Mvux/Assets/Mvvm.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/Overview/Mvux/Assets/MvvmWeather.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/Overview/Mvux/Assets/MvvmWeatherUpdated.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions doc/Overview/Mvux/FeedView.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ uid: Overview.Mvux.FeedView

# The `FeedView` control

The `FeedView` control is the heart of MVUX on the View side and is one of the main way to consume Feeds and States within an application. The `FeedView` uses different visual states to control what is displayed on the screen depending on the state of the underlying feed, or state.
The `FeedView` control is one of the main ways to consume Feeds and States within an application. The `FeedView` uses different visual states to control what is displayed on the screen depending on the state of the underlying feed, or state.

## How to use the `FeedView` control

Expand Down Expand Up @@ -55,9 +55,7 @@ In the above example, [`Data`](#data) is a property of the `FeedViewState` insta

### State

The `State` property provides a `FeedViewState` which exposes the current state of the `FeedView`'s underlying data Feed wrapped in its metadata in an accessible way for the View to represent easily using the built-in or the customized templates accordingly.

It's unlikely that you'll need to access the `State` property directly since the `FeedViewState` is automatically set as the `DataContext` of the various templates.
The `State` property returns a `FeedViewState` which exposes the current state of the `FeedView`'s underlying data Feed. It's unlikely that you'll need to access the `State` property directly since the `FeedViewState` is automatically set as the `DataContext` of the various templates.

#### The `FeedViewState` object

Expand Down
4 changes: 2 additions & 2 deletions doc/Overview/Mvux/Feeds.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Feeds include additional metadata that indicates whether the operation is still

Feeds are typically used to request data from services and expose it in a stateless manner so that the resulting data can be displayed by the View.

Feeds are stateless and do not provide support for reacting upon 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 Async-Enumerable will be invoked and the data refreshed. In other words, a feed is a read-only representation of the data received from the server.
Feeds are stateless and does 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 Async-Enumerable will be invoked and the data refreshed. In other words, a feed is a read-only representation of the data received from the server.
nickrandolph marked this conversation as resolved.
Show resolved Hide resolved

In contrast to feeds, [states](xref:Overview.Mvux.States) (`IState` or `IListState`), as the name suggests, are stateful and keep track of the latest value, as updates are applied.

Expand Down Expand Up @@ -115,7 +115,7 @@ public void SetUp()

#### Awaiting feeds

Feeds are directly awaitable, so to get the data currently held in the feed, this is useful when you want to use the current value in a command, etc. You can await it in the following manner:
Feeds are directly awaitable, so to get the data currently held in the feed, the feed needs to be awaited. This is useful when you want to use the current value in a method, for example:

```csharp
public IFeed<CurrentCount> CurrentCount => ...
Expand Down
9 changes: 2 additions & 7 deletions doc/Overview/Mvux/ListStates.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ public IListFeed<string> FavoritesFeed => ...
public IListState<string> FavoritesState => ListState.FromFeed(this, FavoritesFeed);
```

## Others

There's also the `ListState.Create` method which allows you to manually build the list-state with Messages.
You can learn about manual creation of Messages [here](xref:Overview.Reactive.State#create).

## Operators

In the following examples, we'll refer to `MyStrings` which is an `IListState<string>`, to demonstrate how to use the various operators `IListState<T>` provides to update its state with modified data.
Expand Down Expand Up @@ -117,7 +112,7 @@ public async ValueTask TrimAll(CancellationToken ct = default)
}
```

Another overload is `UpdateAsync`, which allows you to apply an update on select item criteria, using a predicate that is checked before updating an individual update, and if an item qualifies, uses the `updater` argument, which in this case is a `Func<T, T>` which applies to an individual item:
Another overload is `UpdateAsync`, which allows you to apply an update on items that match a criteria. The `match` predicate is checked for each item.It the item matches the criteria, the updater is invoked which returns a new instance of the item with the update applied:
nickrandolph marked this conversation as resolved.
Show resolved Hide resolved

```csharp
public async ValueTask TrimLongNames(CancellationToken ct = default)
Expand All @@ -141,7 +136,7 @@ The `RemoveAllAsync` method uses a predicate to determine which items are to be

### ForEachAsync

This operator can be called from an `IListState<T>` to execute an asynchronous action on all items currently in the list-state each time its data is changed (values are either added or removed):
This operator can be called from an `IListState<T>` to execute an asynchronous action then the data changes. The action is invoked once for the entire set of data, rather than for individual items:
nickrandolph marked this conversation as resolved.
Show resolved Hide resolved

```csharp
await MyStrings.ForEachAsync(async(list, ct) => await PerformAction(items, ct));
Expand Down
Loading