Skip to content
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

Properly introduce @vue/composition-api to the project #629

Closed
stefandesu opened this issue Oct 22, 2021 · 1 comment
Closed

Properly introduce @vue/composition-api to the project #629

stefandesu opened this issue Oct 22, 2021 · 1 comment
Milestone

Comments

@stefandesu
Copy link
Member

@vue/composition-api allows us to use Vue 3's composition API in Vue 2. I want to (slowly) introduce the composition API in Cocoda. First, it would be helpful to have it for #608, and in the long run it would make the move to Vue 3 easier (#583). We could slowly replace mixins as well. This would make the project more structured and future changes will be easier.

Note that since moving to Vite, @vue/composition-api is already a dependency of Cocoda, but it is not yet fully added to the project. To add it to the project, first add a new file src/composition/index.js:

import Vue from "vue"
import VueCompositionApi from "@vue/composition-api"
Vue.use(VueCompositionApi)
export * from "@vue/composition-api"

Then, whenever we need methods from the composition API, we can use import { reactive } from "@/composition".

Note that this also requires on change to the Vite config to use the @ alias (which refers to the src/ directory and makes it easier to deal with nested imports):

{
  resolve: {
    alias: {
      "@": resolve(__dirname, "./src"),
    },
  }
}

We can then change many of the imports to use this @ alias.

@stefandesu stefandesu added this to the 1.5.0 milestone Oct 22, 2021
@stefandesu
Copy link
Member Author

composition-api is now properly added to the project. Note that you can also use `import { reactive } from "@vue/composition-api" now to get typeahead support etc.

While composition-api isn't used anywhere in the project yet (apart from the entry points), this issue was only about the preparation to be used elsewhere (for example for #608), so I'm closing this issue.

However, it makes sense to slowly change components and mixins to use the composition-api.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant