Nuxt plugins Helper

Nuxt plugins 機能を利用して登録されたHelperを用いて状態を管理します。

項目

How it works

Nuxt plugins機能を利用して登録されたHelperを用いて状態を管理します。

State URI

URI helper://{**path}
Scheme helper
Path Nuxt plugins Helper へのパスとファイル名を指定します。
Example helper://{**path}

plugin Helper API

Nuxt pluginsを登録します。

主にActionTransformで利用されることを想定しています。

ts
import type { ICombadgeNuxtHelperProps } from "../../src/runtime/composables/useCombadgeHelper"

export default defineNuxtPlugin(() => {
  return {
    provide: {
      counter: (props: ICombadgeNuxtHelperProps) => {
        console.log(props)
        switch (props.method) {
          case "get":
            throw new Error("NotSupported");
          case "set":
            throw new Error("NotSupported");
          case "action":
            {
              const parsed = parseInt(props.data) || 0
              switch (props.params) {
                case "up":
                  return parsed + 1
                case "down":
                  return parsed - 1
              }
              break;
            }
        }
        return props.data;
      }
    }
  }
})