mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-13 06:13:03 -05:00
feat(callstatelib): add a callstate publishable lib
This commit is contained in:
18
libs/shared/ngrx-callstate-store/src/lib/external.model.ts
Normal file
18
libs/shared/ngrx-callstate-store/src/lib/external.model.ts
Normal 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 });
|
||||
Reference in New Issue
Block a user