All files / src/classes CoreKernelExtension.ts

100% Statements 2/2
100% Branches 1/1
100% Functions 1/1
100% Lines 2/2

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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55                                                                                              1x 1x            
import type {
  ICoreCache,
  ICoreClient,
  ICoreElement,
  ICoreKernel,
  ICoreKernelModule,
  ICorePresenter,
  IDataBase,
} from '../lib';
import CoreElement from './CoreElement';
 
/**
 * An abstract base class for kernel extensions that integrates a kernel module
 * into the core element infrastructure.
 *
 * @template K  The type of kernel that this extension will interact with,
 *               defaulting to {@link ICoreKernel<any>}.
 * @template T  The database type used by the kernel, which may be {@link IDataBase<any, any>}
 *               or {@code null} if the extension does not use a database.
 * @template P  The client type used by the kernel, which may be {@link ICoreClient}
 *               or {@code null}.
 * @template C  The cache type used by the kernel, which may be {@link ICoreCache}
 *               or {@code null}.
 * @template E  The presenter type used by the kernel, which may be {@link ICorePresenter<any>}
 *               or {@code null}.
 *
 * Extends {@link CoreElement} and implements {@link ICoreElement}, thereby inheriting
 * core element lifecycle management while providing additional functionality specific
 * to kernel extensions.
 */
export default abstract class CoreKernelExtension<
    K extends ICoreKernel<any> = ICoreKernel<any>,
    T extends IDataBase<any, any> | null = any,
    P extends ICoreClient | null = any,
    C extends ICoreCache | null = any,
    E extends ICorePresenter<any> | null = any,
  >
  extends CoreElement<K, T, P, C, E>
  implements ICoreElement<K, T, P, C, E>
{
  skipKernelStart;
 
  constructor(
    channel: string,
    module: ICoreKernelModule<K, T, P, C, E>,
    skipKernelStart = false,
  ) {
    super(`ex-${channel}`, module);
    this.skipKernelStart = skipKernelStart;
  }
 
  abstract start(): Promise<void>;
  abstract stop(): Promise<void>;
}