@@ -23,7 +23,7 @@ public class CartService : ICartService
23
23
// The method must be virtual + return Task<T>
24
24
public virtual async Task <List <Order >> GetOrders (long cartId , CancellationToken cancellationToken )
25
25
{
26
- // ...
26
+ // Implementation goes here
27
27
}
28
28
}
29
29
```
@@ -81,20 +81,20 @@ public interface ICartClientDef
81
81
82
82
Configure Fusion client (this has to be done once in a code that configures client-side ` IServiceProvider ` ):
83
83
``` cs
84
- var baseUri = new Uri (" http://localhost:5005" );
85
- var apiBaseUri = new Uri ($" {baseUri }api/" );
86
-
87
- var fusion = services .AddFusion ();
88
- fusion .AddRestEaseClient (
89
- client => {
90
- client .ConfigureWebSocketChannel (_ => new () { BaseUri = baseUri });
91
- client .ConfigureHttpClient ((_ , name , o ) => {
92
- var isFusionClient = (name ?? " " ).StartsWith (" Stl.Fusion" );
93
- var clientBaseUri = isFusionClient ? baseUri : apiBaseUri ;
94
- o .HttpClientActions .Add (httpClient => httpClient .BaseAddress = clientBaseUri );
95
- });
96
- client .AddReplicaService <ITodoService , ITodoClientDef >();
84
+ var baseUri = new Uri (" http://localhost:5005" );
85
+ var apiBaseUri = new Uri ($" {baseUri }api/" );
86
+
87
+ var fusion = services .AddFusion ();
88
+ fusion .AddRestEaseClient (
89
+ client => {
90
+ client .ConfigureWebSocketChannel (_ => new () { BaseUri = baseUri });
91
+ client .ConfigureHttpClient ((_ , name , o ) => {
92
+ var isFusionClient = (name ?? " " ).StartsWith (" Stl.Fusion" );
93
+ var clientBaseUri = isFusionClient ? baseUri : apiBaseUri ;
94
+ o .HttpClientActions .Add (httpClient => httpClient .BaseAddress = clientBaseUri );
97
95
});
96
+ client .AddReplicaService <ITodoService , ITodoClientDef >();
97
+ });
98
98
```
99
99
100
100
Register Replica Service:
@@ -204,7 +204,7 @@ Capture:
204
204
var computed = await Computed.Capture(ct => service.ComputeMethod(args, ct), cancellationToken);
205
205
```
206
206
207
- Check its state :
207
+ Check whether `IComputed` is still consistent :
208
208
```cs
209
209
if (computed.IsConsistent()) {
210
210
// ...
@@ -213,6 +213,10 @@ if (computed.IsConsistent()) {
213
213
214
214
Await for invalidation:
215
215
```cs
216
+ // Always pass CancellationToken here, otherwise you'll
217
+ // end up with a memory leak due to growing number of
218
+ // event handler registrations. They'll be gone on
219
+ // invalidation, of course, but what if it never happens?
216
220
await computed.WhenInvalidated(cancellationToken);
217
221
// Or
218
222
computed.Invalidated += c => Console.WriteLine("Invalidated!");
0 commit comments