nuxt-ioc

Nuxt IOC implementation
5,235 7
Install
npm install nuxt-ioc
Latest Version:1.2.1
Vue:2
License:ISC
Last Updated:Jan 10, 2024
Links: GitHub  ·  npm
Maintainer: mateuszgachowski

nuxt-ioc - IOC containers for Vue/Nuxt frameworks

IoC/DI for Nuxt.js framework powered by Inversify.js and inspired by great Java Spring and Nest.js frameworks.

Requirements

Quick start

Please refer to our documentation for complete guide.

Example code

<template>
  <div>My component content</div>
</template>

<script lang="ts">
  import { Injectable, BaseComponent, Inject, factory } from 'nuxt';
  import MyService from '~/Application/MyService';

  @Injectable()
  export class MyComponent extends BaseComponent {
    @Inject(MyService)
    private gMyService: MyService;

    public async $fetch(): Promise<void> {
      await this.gMyService.getMyData();
    }

    public $mounted(): void {
      console.log('this is Vue mounted life hook');
    }
  }

  export default factory(MyComponent);
</script>

Local Test

If you want test our example locally, you need change coreModule ind the index.ts

const options = {
  // @ts-ignore
  containerPath: '~/Application/container',
  coreModule: '../../',
  // coreModule: 'nuxt-ioc',
  ...moduleOptions,
};

Related Packages

vue-di-container

Dependency injection container for Vue

1,561 1
@scayle/storefront-nuxt

Nuxt integration for the SCAYLE Commerce Engine and Storefront API

152,903
nuxt-tsconfig-stub

Stub Nuxt's generated tsconfig.json at installation

70,835 24
@kaokei/use-vue-service

Lightweight Vue 3 state management with dependency injection, inspired by Angula...

1,891 5
kuranuxt

Look at the Nuxt 3 documentation to learn more.

871 0

Version History

Version Released Vue License
1.2.1 2.6.12 ISC
1.2.0 2.6.12 ISC
1.1.0 2.6.12 ISC
1.0.18 2.6.12 ISC
1.0.17 2.6.12 ISC