MartinMalinda / vue-concurrency

A library for encapsulating asynchronous operations and managing concurrency for Vue and Composition API.
https://vue-concurrency.netlify.app/
MIT License
352 stars 15 forks source link

Improve performance of drop() #4

Open MartinMalinda opened 4 years ago

MartinMalinda commented 4 years ago

These optimizations might be useful if the task is used very extensively, on scroll or raf or smilar (intense throttling).

Task is being marked as drop after quite some work of creating a new reactive object. Dropped task instance never changes though and all the set up of reactive() and computed() is not needed.

A simple static object that implements the TaskInterface could be returned right away.


Alternatively, a task could be set up not to even create dropped task instances and just early return from perform().

// for those who are brave
const task = useTask(function * () { /* ... */ }).drop({ void: true });