seamless-injector
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Build Status Coverage Status

NPM

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');

Readme

Keywords

none

Package Sidebar

Install

npm i seamless-injector

Weekly Downloads

12

Version

1.0.5

License

ISC

Unpacked Size

28.4 kB

Total Files

56

Last publish

Collaborators

  • vforv