seamless-injector
v1.0.5
Published
Better way to manage dependencies
Downloads
13
Readme
Example:
// Window.ts
import { Event } from 'seamless-injector';
@Event('SingletonPattern')
export class Window {
private windowSize: number;
constructor() {
this.windowSize = Math.random();
}
public get() {
return 'Window';
}
public size() {
return this.windowSize;
}
}
// House.ts
import { Event, Getter } from '../Event';
import { Window } from './Window';
@Event('DefaultPattern')
export class House {
public register() {
const window = Getter<any>('Window');
console.log(`House has ${window.get()}`);
}
}
//index.ts
import './Window';
import { House } from './House';
const house = new House();
house.register();
To mock event just call
import { Register } from 'seamless-injector';
Register.mock(WindowsMock, 'DefaultPattern');