aurelia / aurelia/http-client

Cancel method is not propagated to then promises

Open
#176 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
60
Forks
57
PR merge metrics
No merged PRs in 30d

Description

**I'm submitting a feature request**

* **Library Version:**
1.2.1

**Current behavior:**
`cancel` method exists only on the promise returned by `send` method. If `then` is called on this promise, the returned promise doesn't have `cancel` method.

```typescript
@autoinject
export class BackendRepository {
constructor(private httpClient: HttpClient) {}

getItems(): Promise {
return this.httpClient.createRequest("/items").asGet().send()
.then((responseData: any) => responseData.data);
}
}
```

In this example, HTTP response needs to be unwrapped from a response envelope to return proper types to TS app. But it can't be cancelled in upper layers of the TS app, where the request was triggered.

**Expected/desired behavior:**

* **What is the expected behavior?**
The promise returned by `then` should have `cancel` method.

* **What is the motivation / use case for changing the behavior?**
To allow cancelling promises after callbacks are applied.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the promise returned by send and the chaining behavior of then in the HTTP client implementation. Verify how cancellation is currently exposed, then determine how a chained promise should retain it and test that cancellation still works after the response callback is applied.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.