@singularsystems/neo-core 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,6 +19,7 @@ export declare class AppService implements IAppService, IAppServiceRegistration
19
19
  * @param symbol Strongly typed service identifier.
20
20
  */
21
21
  get<T>(symbol: ServiceIdentifier<T>): T;
22
+ tryGet<T>(symbolOrSid: ServiceIdentifier<T> | symbol): T | null;
22
23
  /**
23
24
  * Register a module
24
25
  * @param module The module
@@ -43,4 +44,8 @@ export interface IAppService {
43
44
  * @param symbol Strongly typed service identifier.
44
45
  */
45
46
  get<T>(symbol: ServiceIdentifier<T>): T;
47
+ /** Gets a service from the container if registered, else null. */
48
+ tryGet<T>(symbol: symbol): T | null;
49
+ /** Gets a service from the container if registered, else null. */
50
+ tryGet<T>(serviceIdentifier: ServiceIdentifier<T>): T | null;
46
51
  }
@@ -1,3 +1,4 @@
1
+ import { ServiceIdentifier } from './ServiceIdentifier';
1
2
  import { NeoContainer } from './NeoContainer';
2
3
  var AppService = /** @class */ (function () {
3
4
  /**
@@ -12,6 +13,15 @@ var AppService = /** @class */ (function () {
12
13
  AppService.prototype.get = function (symbolOrSid) {
13
14
  return this.container.get(symbolOrSid);
14
15
  };
16
+ AppService.prototype.tryGet = function (symbolOrSid) {
17
+ var symbol = (symbolOrSid instanceof ServiceIdentifier) ? symbolOrSid.symbol : symbolOrSid;
18
+ if (this.container.isBound(symbol)) {
19
+ return this.container.get(symbol);
20
+ }
21
+ else {
22
+ return null;
23
+ }
24
+ };
15
25
  /**
16
26
  * Register a module
17
27
  * @param module The module
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singularsystems/neo-core",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Core functionality for the Neo client library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",