Fauna v10 .NET/C# Driver 1.0.1
 
Loading...
Searching...
No Matches
FeedEnumerable.cs
Go to the documentation of this file.
1using Fauna.Types;
2
3namespace Fauna.Core;
4
5
10public class FeedEnumerable<T> where T : notnull
11{
12 private readonly BaseClient _client;
13 private readonly EventSource _eventSource;
14 private readonly CancellationToken _cancel;
15
19 public string? Cursor => CurrentPage?.Cursor;
20
24 public FeedPage<T>? CurrentPage { get; private set; }
25
26 internal FeedEnumerable(
27 BaseClient client,
28 EventSource eventSource,
29 CancellationToken cancel = default)
30 {
31 _client = client;
32 _eventSource = eventSource;
33 _cancel = cancel;
34 }
35
40 public async IAsyncEnumerator<FeedPage<T>> GetAsyncEnumerator()
41 {
42 await using var subscribeFeed = _client.SubscribeFeed<T>(
43 _eventSource,
44 _client.MappingCtx,
45 _cancel);
46
47 while (!_cancel.IsCancellationRequested && await subscribeFeed.MoveNextAsync())
48 {
49 CurrentPage = subscribeFeed.Current;
50 yield return CurrentPage;
51 }
52 }
53}
The base class for Client and DataContext.
Definition IClient.cs:370
Represents a Fauna Event Feed.
FeedPage< T >? CurrentPage
The latest page returned from the Event Feed enumerator.
async IAsyncEnumerator< FeedPage< T > > GetAsyncEnumerator()
Returns an enumerator that iterates through the Feed.
string? Cursor
Current cursor for the Feed.
Represents the response from Fauna Event Feed requests.
Definition FeedPage.cs:14
Represents a Fauna EventSource for initializing Streams and Feeds.
Definition EventSource.cs:9