feat(callstatelib): add a callstate publishable lib

This commit is contained in:
thomas
2022-12-07 16:03:05 +01:00
parent 278e513538
commit 1ec45ce141
19 changed files with 1477 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
/* eslint-disable @typescript-eslint/no-empty-interface */
import { ClassProvider, InjectionToken, Type } from '@angular/core';
import { CallStateErrorHandler } from './call-state.model';
export interface ErrorHandler<T extends CustomError> {
toError: (error: unknown) => T;
getErrorMessage: (error?: T) => string | undefined;
}
export interface CustomError {}
export const ERROR_TOKEN = new InjectionToken<ErrorHandler<any>>('error', {
factory: () => new CallStateErrorHandler(),
});
export const provideErrorHandler = <T extends ErrorHandler<any>>(
errorHandlerClass: Type<T>
): ClassProvider => ({ provide: ERROR_TOKEN, useClass: errorHandlerClass });