npm.io
0.3.2 • Published 6 years ago

anyioc

Licence
MIT
Version
0.3.2
Deps
0
Size
39 kB
Vulns
0
Weekly
0

anyioc

Build Status npm

Another simple ioc framework for javascript/typescript.

Install

for Node

npm install anyioc
for Browser

Use packed file dist.browser/anyioc.js.

Usage

import { ServiceProvider } from "anyioc";
const provider = new ServiceProvider();
provider.registerSingleton('the key', ioc => 102); // ioc will be scoped ServiceProvider
value = provider.get('the key'); // 102

There are some predefined key you can use direct, but you still can overwrite it:

  • ioc - get current scoped ServiceProvider instance.
  • provider - alias of ioc

Keywords