nuxt-ioc
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

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,
};

Readme

Keywords

Package Sidebar

Install

npm i nuxt-ioc

Weekly Downloads

86

Version

1.2.1

License

ISC

Unpacked Size

499 kB

Total Files

30

Last publish

Collaborators

  • mateuszgachowski