Skip to content

Instantly share code, notes, and snippets.

@MihaZupan
Last active February 23, 2019 17:33
Show Gist options
  • Save MihaZupan/7e5e1673289e2b895c534d7a39e58397 to your computer and use it in GitHub Desktop.
Save MihaZupan/7e5e1673289e2b895c534d7a39e58397 to your computer and use it in GitHub Desktop.
// doesn't block
void StartReceiving(Func<Update, Task> updateHandler, Func<Exception, Task> exceptionHandler);
// awaitable blocking task
async Task ReceiveAsync(Func<Update, Task> updateHandler, Func<Exception, Task>? exceptionHandler);
// calls GetUpdates after all updates are processed
async IAsyncEnumerable<Update> YieldUpdatesAsync(Func<Exception, Task>? exceptionHandler);
// keeps calling GetUpdates and enqueues updates internally, yielding them one by one
// implementation and different variants TBD
async IAsyncEnumerable<Update> YieldQueuedUpdatesAsync(Func<Exception, Task>? exceptionHandler);
// All variants also have optional `UpdateType[]?` and `CancellationToken` parameters.
// `exceptionHandler` is optional, except on `StartReceiving`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment