armankuanysh/vgent

Feature request - Add composables directory

Opened this issue · 1 comments

Something I found missing was boilerplate for composables. As I have adopted the composables api, I'm refactoring out features and reactive code to be reused.

My Feature request is add an option to generate this boilerplate.
For the cli switch because composables are often named useX, -u makes sense to me.

vgent make -u <composable_name>

The default directory for composables is src/composables.

Here is an example template for a composable named useFeature.ts

export interface UseFeatureOptions {}

/**
 * useFeature
 */
export function useFeature(options: UseFeatureOptions = {}) {
  const {
    // add default for each option
  } = options

  return {}
}

export type UseFeatureReturn = ReturnType<typeof useFeature>

Anywhere that useFeature is should be replaced with <composable_name>.

For TypeScript that's the minimum common boilerplate.

Hello! Thank you for your feedback. I've added this request to milestone