Fauna v10 .NET/C# Driver 1.0.1
 
Loading...
Searching...
No Matches
StreamEnumerable.cs
Go to the documentation of this file.
1using Fauna.Types;
2
3namespace Fauna.Core;
4
9public class StreamEnumerable<T> where T : notnull
10{
11 private readonly BaseClient _client;
12 private readonly EventSource _eventSource;
13 private readonly CancellationToken _cancel;
14
18 public string Token => _eventSource.Token;
19
20 internal StreamEnumerable(
21 BaseClient client,
22 EventSource eventSource,
23 CancellationToken cancel = default)
24 {
25 _client = client;
26 _eventSource = eventSource;
27 _cancel = cancel;
28 }
29
34 public async IAsyncEnumerator<Event<T>> GetAsyncEnumerator()
35 {
36 await using var subscribeStream = _client.SubscribeStream<T>(
37 _eventSource,
38 _client.MappingCtx,
39 _cancel);
40
41 while (!_cancel.IsCancellationRequested && await subscribeStream.MoveNextAsync())
42 {
43 yield return subscribeStream.Current;
44 }
45 }
46}
The base class for Client and DataContext.
Definition IClient.cs:370
A class representing a Fauna Event Stream. Additional queries will be made during enumeration.
string Token
The token for the event source.
async IAsyncEnumerator< Event< T > > GetAsyncEnumerator()
Gets an async enumerator for the stream.
Represents a Fauna EventSource for initializing Streams and Feeds.
Definition EventSource.cs:9