dotnet / dotnet/reactive

Consider adding FromAsyncWithPostCancelNotifications

Open
#1,966 1 comment 0 reactions 1 assignee Claimed by @idg10 View on GitHub
[area] Rx feature request
Dominant language
C#
Stars
7.2k
Forks
798
PR merge metrics
No merged PRs in 30d

Description

The [ReactiveUI](https://github.com/reactiveui/ReactiveUI) project uses Rx's ability to wrap a `Task` as an `IObservable`, but there's a capability they have wanted for a long time that Rx currently does not offer: the ability both to cancel the underlying task and to observe its progress after cancellation.

There's no built in way to do this, because the mechanism by which you cancel a `Task` wrapped in an `IObservable` is to unsubscribe (i.e. to call `Dispose` on the `IDisposable` returned by `Subscribe`). The problem with this is that unsubscribing tells Rx that you don't want to receive any more notifications.

https://github.com/reactiveui/ReactiveUI/issues/2153 describes a problem in ReactiveUI that can be attributed to this missing Rx capability.

Although this is not insurmountable, as the PR at https://github.com/reactiveui/ReactiveUI/pull/3556 shows, it would would be useful if Rx provided an out-of-the-box solution to this. We could do this by providing something like the `FromAsyncWithPostCancelNotifications` extension method defined by that PR:

https://github.com/reactiveui/ReactiveUI/pull/3556/files#diff-41fb8479ae2ebc5305bca72fa394bd5bdf8d13b1806c76ca65a6878e8954f075R103-R122

As @ChrisPulman points out at https://github.com/reactiveui/ReactiveUI/pull/3556#issuecomment-1575278125 we would need a set of overloads to cover all the variations.

`FromAsyncWithPostCancelNotifications` might not be the ideal name for this, but we can give that some thought later.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.