strikejs-app-service
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

strikejs-app-service

A recursive service registry that can be used as a dependency container in JavaScript applications.

Usage

 
import {AppService} from 'strikejs-app-service';
 
const registry = new AppService(); 
 
registry.set('someService', ()=>'some Value');
 
// notice that it returns a promise 
registry.get('someService').then(console.log);
 
// you can provie a function that returns a promise
// this is useful for code splitting 
registry.set('someOtherService', ()=>Promise.resolve('some Value'));
 
// or import a file using `import`
registry.set('someService', () => import('./test'))
 
registry.get('someOtherService').then(console.log);
 
// you can also access other dependencies
registry.set('someService', async (registry) => {
  const someOtherDependency = await registry.get('someOtherSerivce');
  return createMyService(someOtherDependency);
});
 

Readme

Keywords

Package Sidebar

Install

npm i strikejs-app-service

Weekly Downloads

2

Version

2.0.2

License

ISC

Unpacked Size

25 kB

Total Files

21

Last publish

Collaborators

  • suhail