1.5.1 • Published 5 years ago

gollumts-service v1.5.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

GollumTS-Service

An implementaion of service injector and manager.

Install:

npm install --save gollumts-service

Example

	
	import { App, Service, ServiceName, Tags, Tagged } from 'gollumts-service';
	
	class Service1 {
		
		@ServiceName();
		public serviceName: string;
		
		@Service()
		private _nameOfService2: Service2;
		
		display(): void {
			this._nameOfService2.display();
		}
		
	}
	
	class Service2 {
		
		@Service('nameOfService3')
		private _serviceReplaceName: Service3;
		
		display(): void {
			this._serviceReplaceName.display();
		}
		
	}
	
	@Tagged('autoTag') // 'Add automaticly a tag on this class'
	class Service3 {
		
		private _text: string;
		
		public constructor(text: string) {
			this._text = text;
		}
		
		display(): void {
			console.log(this._text);
		}
		
	}
	
	class Main extends App {
		
		@Service()
		private _nameOfService1: Service1;
		
		@Tag()
		private _tags1: any[];
		
		@Tag('tag2')
		private _tags2CustomName: any[];
		
		@Tag()
		private _autoTag: any[];
		
		start(): void {
			
			this.declare('nameOfService1', Service1);
			this.declare('nameOfService2', Service2);
			this.set('nameOfService3', new Service3('Hello World'));
			this.declare('nameOfService3WithParams', Service3, { args: ['Hello World'] });
			
			this.declare('taggedService1', Service1, { tags: [ 'tags1' ] });
			this.declare('taggedService2', Service2, { tags: [ 'tags1', 'tag2' ] });
			
			this._nameOfService1.display();
			
			this._tags1[0].display(); // Hello World
			
			console.log(this._nameOfService1.serviceName); // nameofservice1
			
		}
		
	}
	
	// Start run
	
	const main = new main();
	main.start();
	
1.5.1

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago