0.8.0 • Published 9 months ago

@rxstack/service-registry v0.8.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

The Service Registry

Simple registry component useful for all types of applications.

Installation

npm install @rxstack/service-registry --save

Documentation

Usage

A registry object acts as a collection of objects. It allows you to store objects which implement a specific interface.

Each service should implement NamedServiceInterface:

    import {NamedServiceInterface} from '@rxstack/registry';

    export class MyService implements NamedServiceInterface {
      getName(): string {
        return 'service-1';
      }
    }

Here we go:

    import {ServiceRegistry} from '@rxstack/registry';

    const registry = new ServiceRegistry<MyServiceInterface>();
    registry.register(new MyService1());
    registry.register(new MyService2());
    
    registry.has('service-1'); // should return true
    registry.get('service-1'); // should get service instance
    registry.all(); // should retun an array of all registered service
    registry.reset(); // clears all services from registry

Removing a service from the registry is as easy as adding:

// ...
registry.unregister('service-1');
registry.has('service-1'); //should return false

Exceptions

ExistingServiceException is thrown when you try to register a service that is already in the registry.

NonExistingServiceException is thrown when you try to unregister or get a service which is not in the registry.

License

Licensed under the MIT license.

0.8.0

9 months ago

0.6.1

3 years ago

0.6.0

4 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.21

7 years ago

0.0.14

7 years ago

0.0.1

8 years ago