vgent icon indicating copy to clipboard operation
vgent copied to clipboard

Feature request - Add composables directory

Open nmarshall23 opened this issue 3 years ago • 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.

nmarshall23 avatar Feb 23 '22 16:02 nmarshall23