Skip to content

Commit

Permalink
injector: use injector in default module
Browse files Browse the repository at this point in the history
  • Loading branch information
codyjdalton committed May 23, 2018
1 parent ce8e7ed commit d4f3f13
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
10 changes: 10 additions & 0 deletions lib/modules/services/some.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* some.service
*/
import { Injectable } from 'super-injector';

@Injectable()
export class SomeService {

public message: string = 'hello';
}
14 changes: 12 additions & 2 deletions lib/modules/some.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@
* new SomeModule().message or
* SomeModuleInst.message
*/
import { Injectable, Injector } from 'super-injector';
import { SomeService } from './services/some.service';
/**
* Class Declaration
*/
@Injectable() // <-- injects dependencies, add dependencies to constructor
export class SomeModule {

/**
* @property {string} messageText - example text
* Usage:
* this.messageTest
*/
private messageText: string = 'hello';
private messageText: string = '';

constructor(private someService: SomeService) {
this.messageText = this.someService.message;
}

/**
* @function message (get)
Expand All @@ -30,4 +40,4 @@ export class SomeModule {
}
}

export const SomeModuleInst: SomeModule = new SomeModule();
export const SomeModuleInst: SomeModule = Injector.resolve(SomeModule);
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {},
"dependencies": {
"super-injector": "^0.1.1"
},
"devDependencies": {
"@types/chai": "*",
"@types/mocha": "*",
Expand Down

0 comments on commit d4f3f13

Please sign in to comment.