Cocoon - v1.0.0
    Preparing search index...

    Function registerDeps

    • Registers an application's dependencies in Vue's DI system.

      Provides the services/factories via Vue's provide/inject system, and optionally attaches a global function to app.config.globalProperties.

      Type Parameters

      • T extends AppDepsMap

        A type extending AppDepsMap representing the container of registered services.

      Parameters

      • app: App

        The Vue application instance.

      • deps: T

        The object containing all services or service factories to register.

      • Optionaloptions: RegisterDepsOptions

        Optional configuration for global attachment.

      Returns void

      import { createApp } from "vue"
      import App from "./App.vue"
      import { registerDeps } from "@your-scope/vue-deps"
      import { UserService, AuthService } from "./services"

      const app = createApp(App)

      registerDeps(app, {
      userService: () => new UserService(),
      authService: () => new AuthService()
      }, {
      globalDeps: true,
      globalDepsNameOverride: "myDeps" // optional custom global function name
      })

      app.mount("#app")
      • If globalDeps is true, the function is available in components via this[globalDepsNameOverride]() in Options API or directly as myDeps() in <script setup>.
      • Lazy initialization of services is handled by createDepsProxy.