All files / platform/core/src/services ServiceProvidersManager.ts

55.55% Statements 5/9
0% Branches 0/2
100% Functions 2/2
55.55% Lines 5/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32                      34x 34x       34x             34x         34x      
import log from './../log.js';
 
/**
 * The ServiceProvidersManager allows for a React context provider class to be registered
 * for a particular service. This allows for extensions to register services
 * with context providers and the providers will be instantiated and added to the
 * DOM dynamically.
 */
export default class ServiceProvidersManager {
  public providers = {};
 
  public constructor() {
    this.providers = {};
  }
 
  registerProvider(serviceName, provider) {
    Iif (!serviceName) {
      log.warn(
        'Attempting to register a provider to a null/undefined service name. Exiting early.'
      );
      return;
    }
 
    Iif (!provider) {
      log.warn('Attempting to register a null/undefined provider. Exiting early.');
      return;
    }
 
    this.providers[serviceName] = provider;
  }
}