-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default concurrency policy config #106
Comments
Hey! You can create a wrapper like this: type Generator = Parameters<typeof useTask>[0];
export function useDropTask(cb: Generator) {
return useTask(cb).drop();
} I'd calll it import { useTask as useTaskOriginal } from 'vue-concurrency';
type Generator = Parameters<typeof useTaskOriginal>[0];
export function useTask(cb: Generator) {
return useTaskOriginal(cb).drop();
} But the big issue here is that So at the end of the day you could go for this setting: import { useTask as useTaskOriginal } from 'vue-concurrency';
type Generator = Parameters<typeof useTaskOriginal>[0];
export function useTask(cb: Generator, concurrency: 'drop' | 'restartable' | 'keepLatest' | null = 'drop') {
const task = useTaskOriginal(cb);
if (concurrency) {
task[concurrency]();
}
}
const myTask = useTask(function*(){
//...
}); // drop
const myOtherTask = useTask(function*() {
// ...
}, 'restartable').
const myOtherTask = useTask(function*() {
// ...
}, null). // this one allows parallel runs I'm not sure if any of these are ideal :D There could totally be global config as that could also solve #50 but so far it's missing. |
Thank you! My problem is solved now. glad to see if theres a global config in new version |
Hello,how can I use
drop
as default concurrency policy? so that I can ignore.drop()
on eachuseTask
call.Also,thanks for this great tool
The text was updated successfully, but these errors were encountered: