My recommendation is to change the search method to an asynchronous call that takes a CancellationToken value as the second argument. You can then convert this to an observable sequence through Observable.ToAsync. A utility call on this observable will trigger the cancellation of the CancellationToken. This makes it easy to transfer the token to asynchronous web calls, etc.
public Task Search(string searchText, CancellationToken cancel)
{
}
var searchSub = Observable.ToAsync(c => this.booksService.Search(searchText, c))
.Subscribe( ... );
searchSub.Dispose();
source
share