Socket
Socket
Sign inDemoInstall

dependency-injection-cat

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dependency-injection-cat

Dependency Injection Cat is a TypeScript-only library which allows you to implement the Dependency Inversion pattern with Dependency Injection


Version published
Weekly downloads
43
decreased by-35.82%
Maintainers
1
Weekly downloads
 
Created
Source

dependency-injection-cat

Dependency Injection Cat is a TypeScript-only library which allows you to implement the Dependency Inversion pattern with Dependency Injection

Installation

Install with yarn

yarn add dependency-injection-cat

Install with npm

npm install dependency-injection-cat

Usage

Simple case

// requesters.diconfig.ts
import { Bean, Qualifier } from 'dependency-injection-cat';
import { IRequester } from '../IRequester';
import { Requester } from '../Requester';
import { ILogger } from '../ILogger';

export class Requesters {
    @Bean
    requester(logger: ILogger): IRequester {
        return new Requester(logger);
    }
    //or
    requester = Bean<IRequester>(Requester);
}

// loggers.diconfig.ts
import { Bean } from 'dependency-injection-cat';
import { ILogger } from '../ILogger';
import { Logger } from '../Logger';

export class Loggers {
    @Bean
    logger(): ILogger {
        return new Logger();
    }
    //or
    @Bean
    logger = Bean<ILogger>(Logger);
}

// main.ts
import { container } from 'dependency-injection-cat';
import { IRequester } from './IRequester';

const requester = container.get<IRequester>();

requester.makeRequest....

Author

  • Artem Kornev

License

This project is under the MIT License

FAQs

Package last updated on 17 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc