MartinMalinda / vue-concurrency

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

when perform() called, TypeError: import_caf.default.cancelToken is not a constructor raised. #41

Closed narusas closed 7 months ago

narusas commented 3 years ago

Hi I try to use cue-concurrency in my project

Vue 3.05 Vue-Concurrency 2.0.3

My code

<script setup>
...
const headBrand = ref({});
const getNavigationCategoryTask = useTask(function*() {
  const res = yield axios.get("/api/sample.json");
  console.log(res);
  headBrand.value =  res.data.data.brnd;
});

getNavigationCategoryTask.perform();
...

But it failed when call perform();

  Uncaught (in promise) TypeError: import_caf.default.cancelToken is not a constructor
    at TaskInstance.ts:175
    at Proxy._run (TaskInstance.ts:207)
    at E (TaskInstance.ts:163)
    at Proxy.perform (Task.ts:139)
    at setup (CategoryPage.vue:552)
    at callWithErrorHandling (runtime-core.esm-bundler.js:154)
    at setupStatefulComponent (runtime-core.esm-bundler.js:6542)
    at setupComponent (runtime-core.esm-bundler.js:6503)
    at mountComponent (runtime-core.esm-bundler.js:4206)
    at processComponent (runtime-core.esm-bundler.js:4182)
(anonymous) @   TaskInstance.ts:175
_run    @   TaskInstance.ts:207
E   @   TaskInstance.ts:163
perform @   Task.ts:139
setup   @   CategoryPage.vue:552
MartinMalinda commented 3 years ago

Hey @narusas , thanks for the report. I havent' encountered this one yet. Is this vue-cli? It might be some npm install problem where caf wasn't installed. caf is a dependency of vue-concurrency