Configuration
When defining a task, a configuration object that can accept the following parameters:
Keep
The keep
property defines whether task instances should be aborted based on another performace of the task.
const [perform] = useTask(
function*() {
// ...
},
{ keep: "last" }
);
last
(default)
Only the last instance of a task will be kept; if the task is performed again while another instance of it is running, the previous instance will be aborted.
first
If the task is performed again while another instance is running, the new instance will be aborted instantly and the previous instance kept running.
all
All instances of a task will be kept; a task instance will never be aborted based on performing the task again.