|
1 | 1 | namespace MediatR.Courier; |
2 | 2 |
|
| 3 | +/// <summary> |
| 4 | +/// Provides functionality for subscribing to and unsubscribing from MediatR notifications |
| 5 | +/// with support for both strong and weak reference handlers. |
| 6 | +/// </summary> |
3 | 7 | public interface ICourier |
4 | 8 | { |
| 9 | + /// <summary> |
| 10 | + /// Subscribes a handler to receive notifications of the specified type. |
| 11 | + /// The handler will be held with a strong reference. |
| 12 | + /// </summary> |
| 13 | + /// <typeparam name="TNotification">The type of notification to subscribe to.</typeparam> |
| 14 | + /// <param name="handler">The handler to invoke when a notification is published.</param> |
5 | 15 | void Subscribe<TNotification>(Action<TNotification> handler) |
6 | 16 | where TNotification : INotification; |
7 | 17 |
|
| 18 | + /// <inheritdoc cref="Subscribe{TNotification}(Action{TNotification})"/> |
| 19 | + /// <typeparam name="TNotification">The type of notification to subscribe to.</typeparam> |
| 20 | + /// <param name="handler">The handler to invoke when a notification is published.</param> |
8 | 21 | void Subscribe<TNotification>(Action<TNotification, CancellationToken> handler) |
9 | 22 | where TNotification : INotification; |
10 | 23 |
|
| 24 | + /// <inheritdoc cref="Subscribe{TNotification}(Action{TNotification})"/> |
| 25 | + /// <typeparam name="TNotification">The type of notification to subscribe to.</typeparam> |
| 26 | + /// <param name="handler">The handler to invoke when a notification is published.</param> |
11 | 27 | void Subscribe<TNotification>(Func<TNotification, Task> handler) |
12 | 28 | where TNotification : INotification; |
13 | 29 |
|
| 30 | + /// <inheritdoc cref="Subscribe{TNotification}(Action{TNotification})"/> |
| 31 | + /// <typeparam name="TNotification">The type of notification to subscribe to.</typeparam> |
| 32 | + /// <param name="handler">The handler to invoke when a notification is published.</param> |
14 | 33 | void Subscribe<TNotification>(Func<TNotification, CancellationToken, Task> handler) |
15 | 34 | where TNotification : INotification; |
16 | 35 |
|
| 36 | + /// <summary> |
| 37 | + /// Subscribes a handler to receive notifications of the specified type using a weak reference. |
| 38 | + /// The handler will be held with a weak reference, allowing the target object to be garbage collected. |
| 39 | + /// </summary> |
| 40 | + /// <typeparam name="TNotification">The type of notification to subscribe to.</typeparam> |
| 41 | + /// <param name="handler">The handler to invoke when a notification is published.</param> |
17 | 42 | void SubscribeWeak<TNotification>(Action<TNotification> handler) |
18 | 43 | where TNotification : INotification; |
19 | 44 |
|
| 45 | + /// <inheritdoc cref="SubscribeWeak{TNotification}(Action{TNotification})"/> |
| 46 | + /// <typeparam name="TNotification">The type of notification to subscribe to.</typeparam> |
| 47 | + /// <param name="handler">The handler to invoke when a notification is published.</param> |
20 | 48 | void SubscribeWeak<TNotification>(Action<TNotification, CancellationToken> handler) |
21 | 49 | where TNotification : INotification; |
22 | 50 |
|
| 51 | + /// <inheritdoc cref="SubscribeWeak{TNotification}(Action{TNotification})"/> |
| 52 | + /// <typeparam name="TNotification">The type of notification to subscribe to.</typeparam> |
| 53 | + /// <param name="handler">The handler to invoke when a notification is published.</param> |
23 | 54 | void SubscribeWeak<TNotification>(Func<TNotification, Task> handler) |
24 | 55 | where TNotification : INotification; |
25 | 56 |
|
| 57 | + /// <inheritdoc cref="SubscribeWeak{TNotification}(Action{TNotification})"/> |
| 58 | + /// <typeparam name="TNotification">The type of notification to subscribe to.</typeparam> |
| 59 | + /// <param name="handler">The handler to invoke when a notification is published.</param> |
26 | 60 | void SubscribeWeak<TNotification>(Func<TNotification, CancellationToken, Task> handler) |
27 | 61 | where TNotification : INotification; |
28 | 62 |
|
| 63 | + /// <summary> |
| 64 | + /// Unsubscribes a handler from receiving notifications of the specified type. |
| 65 | + /// </summary> |
| 66 | + /// <typeparam name="TNotification">The type of notification to unsubscribe from.</typeparam> |
| 67 | + /// <param name="handler">The handler to remove from the subscription list.</param> |
29 | 68 | void UnSubscribe<TNotification>(Action<TNotification> handler) |
30 | 69 | where TNotification : INotification; |
31 | 70 |
|
| 71 | + /// <inheritdoc cref="UnSubscribe{TNotification}(Action{TNotification})"/> |
| 72 | + /// <typeparam name="TNotification">The type of notification to unsubscribe from.</typeparam> |
| 73 | + /// <param name="handler">The handler to remove from the subscription list.</param> |
32 | 74 | void UnSubscribe<TNotification>(Action<TNotification, CancellationToken> handler) |
33 | 75 | where TNotification : INotification; |
34 | 76 |
|
| 77 | + /// <inheritdoc cref="UnSubscribe{TNotification}(Action{TNotification})"/> |
| 78 | + /// <typeparam name="TNotification">The type of notification to unsubscribe from.</typeparam> |
| 79 | + /// <param name="handler">The handler to remove from the subscription list.</param> |
35 | 80 | void UnSubscribe<TNotification>(Func<TNotification, Task> handler) |
36 | 81 | where TNotification : INotification; |
37 | 82 |
|
| 83 | + /// <inheritdoc cref="UnSubscribe{TNotification}(Action{TNotification})"/> |
| 84 | + /// <typeparam name="TNotification">The type of notification to unsubscribe from.</typeparam> |
| 85 | + /// <param name="handler">The handler to remove from the subscription list.</param> |
38 | 86 | void UnSubscribe<TNotification>(Func<TNotification, CancellationToken, Task> handler) |
39 | 87 | where TNotification : INotification; |
40 | 88 | } |
0 commit comments