Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(geography): create injection tokens with factory #3249

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { InjectionToken } from '@angular/core';
import { Observable } from 'rxjs';

import { createSingleInjectionToken } from '@daffodil/core';
import { DaffCountry } from '@daffodil/geography';

export const DaffGeographyDriver = new InjectionToken<DaffGeographyServiceInterface>('DaffGeographyDriver');
export const {
token: DaffGeographyDriver,
provider: daffProvideGeographyDriver,
} = createSingleInjectionToken<DaffGeographyServiceInterface>('DaffGeographyDriver');

export interface DaffGeographyServiceInterface<T extends DaffCountry = DaffCountry> {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { InjectionToken } from '@angular/core';

import { createSingleInjectionToken } from '@daffodil/core';
import { daffTransformErrorToStateError } from '@daffodil/core/state';

/**
* Transforms `DaffError`s into `DaffStateError`s before they are serialized into state.
* Can be used to further refine Daffodil errors into more specific app errors.
*/
export const DAFF_GEOGRAPHY_ERROR_MATCHER = new InjectionToken<typeof daffTransformErrorToStateError>(
export const {
token: DAFF_GEOGRAPHY_ERROR_MATCHER,
provider: daffProvideGeographyErrorMatcher,
} = createSingleInjectionToken<typeof daffTransformErrorToStateError>(
'DAFF_GEOGRAPHY_ERROR_MATCHER',
{ factory: () => daffTransformErrorToStateError },
);
2 changes: 1 addition & 1 deletion libs/geography/state/src/injection-tokens/public_api.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { DAFF_GEOGRAPHY_ERROR_MATCHER } from './error-matcher.token';
export * from './error-matcher.token';
Loading