alexlafroscia / use-task

A React hook for running and cancelling asynchronous tasks
https://use-task.now.sh
24 stars 1 forks source link

Provide API for Limiting Concurrent Tasks #3

Open alexlafroscia opened 5 years ago

alexlafroscia commented 5 years ago

Currently, there is just one configuration option for tasks: keep. It has the following values

last (default): Cancel a currently-running instance when running another first: Immediately cancel a new instance of a task if there's another one running all: No tasks are cancelled as a side effect of running another task

I want to expand this API to handle keeping more than just one instance under last and first. Something like this:

useTask(action, { keep: 'last', maxConcurrent: 3 })

The idea is to support something akin to maxConcurrency in ember-concurrency

http://ember-concurrency.com/api/TaskProperty.html#maxConcurrency