1.0.3 • Published 3 years ago

marv_injector v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

marv_injector

A lightweight dependency injection container for TypeScript/JavaScript for constructor injection.

Installation

Install by npm

npm install --save marv_injector

Modify your tsconfig.json to include the following settings

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

Add a polyfill for the Reflect API (examples below use reflect-metadata). You can use:

The Reflect polyfill import should only be added once, and before DI is used:

// main.ts
import "reflect-metadata";

// Your code here...

API

Marv_injector performs Constructor Injection on the constructors of decorated classes.

Decorators

injector()

Class decorator factory that allows the class' dependencies to be injected at runtime.

Usage

import {injector} from "marv_injector";

@injector()
class Foo {
  constructor(private database: Database) {}
}



# Contributing

This project welcomes contributions and suggestions.
1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago