Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed Dec 13, 2024
1 parent 85b337b commit fcc9765
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/content/docs/client/mediator/middleware/mainthread.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ user to confirm an action or request permission to use some device hardware. We

:::note
The main thread middleware is used as part of the default middleware installed by Shiny.Mediator.Maui. Like most
other middleware, you simply need to mark your Handle method(s) with the attribute `[MainThread]`.
other middleware, you simply need to mark your Handle method(s) with the attribute `[MainThread]`. However, UNLIKE other middleware,
configuration of this functionality is not available.
:::

## Event Handler Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ Performance logging middleware is installed by the default mediator setup
"Mediator": {
"PerformanceLogging": {
"My.Contracts.*": {
"*": {
"ErrorThresholdMilliseconds": 1000
}
"ErrorThresholdMilliseconds": 1000
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/content/docs/client/mediator/middleware/refresh.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ There are scenarios where you want to have data requests be called every so ofte

## Attribute Setup
```csharp
public class MyRequest : IStreamRequest<string>;

[RefreshTimer(3000)] // every 3 seconds
public class MyStreamRequestHandler : IStreamRequestHandler<MyRequest, string>
{
Expand All @@ -17,6 +19,17 @@ public class MyStreamRequestHandler : IStreamRequestHandler<MyRequest, string>
yield return DateTimeOffset.Now.ToString("h:mm:ss tt");
}
}

```
and now in your code, you can simply call the mediator to get the stream and await foreach

```csharp
```csharp
var stream = mediator.Request(new MyRequest());
await foreach (var item in stream)
{
// this code will be called every 3 seconds
}
```

## Configuration
Expand Down
4 changes: 3 additions & 1 deletion src/content/docs/client/mediator/middleware/replay.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ The `Replay` middleware is designed to help you with this.
So here we have a standard HTTP call on our streaming async enumerable protocol. Nothing special here, but once we turn on the `Replay` middleware, we can return the previous results while the current network call is in progress.

```csharp
public class MyRequest : IStreamRequest<string>;

public class MyStreamRequestHandler : IStreamRequestHandler<MyRequest, SomeResponse>
{
public async IAsyncEnumerable<string> Handle(MyRequest request, [EnumeratorCancellation] CancellationToken cancellationToken)
Expand Down Expand Up @@ -57,5 +59,5 @@ WE STRONGLY DISCOURAGE THIS. This feature is something you want to be very expl
:::

:::note
This middleware is installed by default with Shiny.Mediator.Maui or Shiny.Mediator.Blazor
This middleware is installed by default with `Shiny.Mediator.Maui` or `Shiny.Mediator.Blazor`
:::
2 changes: 1 addition & 1 deletion src/content/docs/client/mediator/middleware/validation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ try
{
mediator.Send(new MyRequest()); // or Request(new MyRequestResult());
}
catch (ValdiateException ex)
catch (ValdidateException ex)
{
// contains a dictionary a property names with the error message(s) for each property
ex.Result.Errors;
Expand Down

0 comments on commit fcc9765

Please sign in to comment.