Race timeout/cancellation/signals at the Task level, drop AssumeNeverEmits - #5
Merged
Merged
Conversation
…Emits RaceWithSignalAndTimer used to force cancellation and timeout into fake Observable<T> branches (via AssumeNeverEmits) just so they could sit in an Observable-level RaceWith next to the real data stream - a workaround for C# having no bottom type. Racing at the Task level instead sidesteps the problem entirely: Task.WhenAny doesn't care that the branches share a type. Also adds a Task-signal overload for racing against an already-existing "only ever faults" task (e.g. a session-closed signal) instead of a CancellationToken. Bump to 0.3.0 - RaceWithSignalAndTimer/RetryAndRaceWithSignalAndTimer now return Task<T> instead of Observable<T>, and AssumeNeverEmits is gone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AssumeNeverEmits existed to fake timeout/cancellation into Observable branches so they could sit in an Observable-level RaceWith next to real data - a workaround for C# having no bottom type. Turns out that's the wrong layer entirely: these signals never produce a value, so racing them belongs at the Task level, where Task.WhenAny doesn't care what type the branches share. RaceWithSignalAndTimer now returns Task directly (no more trailing .FirstValueFrom()), and there's a new overload for racing against an already-existing "only ever faults" task instead of a CancellationToken.
Bumped to 0.3.0 for the breaking return-type change.