Skip to content

Consider adding FromAsyncWithPostCancelNotifications #1966

Open
@idg10

Description

@idg10

The ReactiveUI project uses Rx's ability to wrap a Task<T> as an IObservable<T>, 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<T> wrapped in an IObservable<T> 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.

reactiveui/ReactiveUI#2153 describes a problem in ReactiveUI that can be attributed to this missing Rx capability.

Although this is not insurmountable, as the PR at reactiveui/ReactiveUI#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 reactiveui/ReactiveUI#3556 (comment) 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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions