# @uxland/ioc

> IOC

Latest version **1.0.4** (published 2023-11-03) · BSD-4-Clause license · 0 weekly downloads

## Install

```sh
npm install @uxland/ioc
pnpm add @uxland/ioc
yarn add @uxland/ioc
bun add @uxland/ioc
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2023-11-03 |
| First published | 2023-01-10 |
| Weekly downloads | 0 |
| License | BSD-4-Clause |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 79.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alex Vizcaino |
| Maintainers | avizcaino, uxland-admin |

## Links

- npm: https://www.npmjs.com/package/@uxland/ioc
- Repository: https://github.com/uxland/uxland
- Homepage: https://github.com/uxland/uxland/tree/master/packages/ioc#readme
- Issues: https://github.com/uxland/uxland/issues
- npm.io page: https://npm.io/package/@uxland/ioc

## Dependencies (3)

- [inversify](https://npm.io/package/inversify.md) ^6.0.1
- [mediatr-ts](https://npm.io/package/mediatr-ts.md) ^0.3.0
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13

## Recent versions

- 1.0.4 (latest) — 2023-11-03
- 1.0.3 — 2023-10-23
- 1.0.2 — 2023-10-23
- 1.0.1 — 2023-01-11
- 1.0.0 — 2023-01-10
- 0.1.0 — 2023-01-10
- 0.0.1 — 2023-01-10

## README

# UXL IOC [![npm version](https://badge.fury.io/js/%40uxland%2Fioc.svg)](https://badge.fury.io/js/%40uxland%2Fioc)

| Build Status                                    | Statements                                    | Branches                                  | Functions                                   | Lines                               |
| ----------------------------------------------- | --------------------------------------------- | ----------------------------------------- | ------------------------------------------- | ----------------------------------- |
| ![BuildStatus](#buildstatus# "Building Status") | ![Statements](#statements# "Make me better!") | ![Branches](#branches# "Make me better!") | ![Functions](#functions# "Make me better!") | ![Lines](#lines# "Make me better!") |

## Installation

`npm i @uxland/ioc`

## Usage

### Register constructor singleton to iocContainer

Registers a constructor singleton to the InversionOfControl container. Each time a reference of the constructor or abstract class is provided with inversify, the container will provide with its singleton pair.

```typescript
@provideSingleton()
class IOCAdapter {
  method(): void {
    console.log("Calling `method` from `IOCAdapter`");
  }
}

class Adapter {
  constructor(@inject(IOCAdapter) protected adapter: IOCAdapter) {
    this.adapter.method(); // => 'Calling `method` from `IOCAdapter`'
  }
}
```

### Set Mediator resolver

This method overrides the mediator default resolver to use our own container.

```typescript
const container: Container = new Container();
setMediatorResolver(container);
```

---
_Source: https://npm.io/package/@uxland/ioc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
