-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(content): create injection tokens with factory (#3265)
- Loading branch information
Showing
2 changed files
with
18 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 12 additions & 10 deletions
22
libs/content/state/src/injection-tokens/error-matcher.token.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_CONTENT_ERROR_MATCHER = new InjectionToken<typeof daffTransformErrorToStateError>( | ||
'DAFF_CONTENT_ERROR_MATCHER', | ||
{ factory: () => daffTransformErrorToStateError }, | ||
); | ||
export const { | ||
/** | ||
* 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. | ||
*/ | ||
token: DAFF_CONTENT_ERROR_MATCHER, | ||
/** | ||
* Provider for {@link DAFF_CONTENT_ERROR_MATCHER}. | ||
*/ | ||
provider: provideDaffContentErrorMatcher, | ||
} = createSingleInjectionToken<typeof daffTransformErrorToStateError>('DAFF_CONTENT_ERROR_MATCHER'); |