0.0.4 • Published 4 years ago
tiniocc v0.0.4
tiniocc
A dead simple IoC container, with lazyload support.
Installation
yarn add tiniocc
or
npm i tiniocc
Usage
// import the exported function
// you can also require it when using CommonJS
// const { createContainer } = require('tiniocc')
import { createContainer } from 'tiniocc'
// create a container
const container = createContainer()
// register a module named 'module' with plain text content 'content'
container.register('module', 'content')
// access the module via dot notation
// will print 'content'
console.log(container.module)
import { createContainer } from 'tiniocc'
const container = createContainer()
container.register('moduleA', 'content')
// register another module which depends on moduleA
container.register('moduleB', container => container.moduleA + ' content')
console.log(container.moduleA) // will print 'content'
console.log(container.moduleB) // will print 'content content'
note: when using with snowpack, you should import the module as follow:
import tiniocc from 'tiniocc'
const container = tiniocc.createContainer()
0.0.4
4 years ago
0.0.3
4 years ago
0.0.2
4 years ago
0.0.2-alpha.1
4 years ago
0.0.2-alpha.0
4 years ago
0.0.1
4 years ago