OpenAPITools / OpenAPITools/openapi-generator

[REQ] [typescript-rxjs] Add cancel event to Middleware

Open
#10,449 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

Using a Middleware is a great way to enhance the requests or responses. However, we use it to

  • enhance the request with a unique id header: progress-key
  • show a progress bar on the UI while at least one request is processed by the server
  • the progress bar queries the status of the requests frequently based on the progress key
  • when all requests are finished, the progress bar is not shown anymore

To hide the progressbar, we use the post(...) function of the middleware. However, sometimes requests are cancelled (e.g.: due to a user interaction) and we cannot catch that event.

Describe the solution you'd like

Add a new function to the middleware:

cancel(requestArgs: RequestArgs);

In case the request is cancelled, this function would be called.

Describe alternatives you've considered

Implement it on the RXJS level. However, in this case the header cannot be added to the request headers automatically.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the typescript-rxjs middleware implementation and the RequestArgs definition. Trace how request, response, and post middleware hooks are invoked during cancellation. Done means a cancelled request invokes the new cancel hook and the middleware behavior is covered by the relevant existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
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.