Skip to content

Add a doc section on composables with guidelines about how to write them in the correct idiomatic way #1293

@julie777

Description

@julie777

There are some significant composable libraries out there. And, since using the composition api and composables is such a great reuse tool it would be nice to know how to avoid problems.

Document the "useFeature" paradigm and how it interacts with the component scope and how reactivity works.
Examples, some of which I still don't understand fully:

  • why the useFeature naming is a good idea
  • does useFeature need to be exported by name like import {useRoute} from 'vue-router or should I export it as the default
  • global vs local/component scope in the composable
  • if I create a composable useFeature and it needs to use vue router then useRouter() must be inside the useFeature function so it ends up in the proper scope in the component.
  • how does reactivity work
    • computed function inside useFeature function
    • computed function outside useFeature function
    • passing a component prop to useFeature(props.something)
    • etc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions