Skip to content

Commit 2f983d8

Browse files
Add description for concrete/concurrencyAbort
1 parent 412175a commit 2f983d8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

EPICS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ We need to give a motivation for each exercise, as well as a concrete example of
9090

9191
### Tasks
9292

93-
- [ ] Concrete - Concurrency Abort
93+
- [x] Concrete - Concurrency Abort
9494
- [ ] Concrete - Concurrency Enqueue
9595
- [ ] Concrete - Concurrency Override
9696
- [ ] Concrete - Extracting Resolvers

src/exercises/concrete/concurrencyAbort/README.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Concurrency Abort
22

3+
**Level: Intermediate**
4+
5+
When dealing with asyncrhonous tasks we need to be aware of the fact that we might have more than one task of the same "kind" running at the same time, that is, **concurrently**, and that might lead to some problems.
6+
7+
A particularly common case is when we have a user interface that deals with pagination and the user selects different pages very quickly, thus firing multiple concurrent requests.
8+
9+
Because the order that these requests complete is **not necessarily** the same as the order they were started, we might end up with a situation where the user sees the results of a page that is not the one they selected last.
10+
11+
In this kind of situation, what we usually do is, whenever a new request comes in, we abort the previous one, so that we only have one request running at a time.
12+
13+
In Javascript promises are **not cancellable**, but while we can't cancel de promise itself, we can abort **whatever runs after the promise completes**, which is what we are going to do here.
14+
15+
In this exercise, we're going to implement a function that calls an async function with a given input, but, whenever it is called while it is already running, we're going to abort the previous call.
16+
17+
## Requirements
18+
319
Implement a function that:
420

521
- Signature: `(input: string) => Promise<string>`

0 commit comments

Comments
 (0)