-
-
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(daffio): create injection tokens with factory (#3267)
- Loading branch information
Showing
2 changed files
with
12 additions
and
14 deletions.
There are no files selected for viewing
17 changes: 7 additions & 10 deletions
17
apps/daffio/src/app/core/assets/fetch/service.interface.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,18 +1,15 @@ | ||
import { | ||
InjectionToken, | ||
inject, | ||
} from '@angular/core'; | ||
import { inject } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
|
||
import { createSingletonInjectionToken } from '@daffodil/core'; | ||
|
||
import { DaffioAssetFetchBrowserService } from './browser.service'; | ||
|
||
export interface DaffioAssetFetchServiceInterface { | ||
fetch<T = unknown>(path: string): Observable<T>; | ||
} | ||
|
||
export const DaffioAssetFetchService = new InjectionToken<DaffioAssetFetchServiceInterface>( | ||
'DaffioAssetFetchService', | ||
{ | ||
factory: () => inject(DaffioAssetFetchBrowserService), | ||
}, | ||
); | ||
export const { | ||
token: DaffioAssetFetchService, | ||
provider: provideDaffioAssetFetchService, | ||
} = createSingletonInjectionToken<DaffioAssetFetchServiceInterface>('DaffioAssetFetchService', { factory: () => inject(DaffioAssetFetchBrowserService) }); |
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,5 +1,6 @@ | ||
import { InjectionToken } from '@angular/core'; | ||
import { createSingleInjectionToken } from '@daffodil/core'; | ||
|
||
export const DAFFIO_DOCS_PATH_TOKEN = new InjectionToken<string>('DAFFIO_DOCS_PATH_TOKEN', { | ||
factory: () => '/assets/daffio/', | ||
}); | ||
export const { | ||
token: DAFFIO_DOCS_PATH_TOKEN, | ||
provider: provideDaffioDocsPath, | ||
} = createSingleInjectionToken<string>('DAFFIO_DOCS_PATH_TOKEN', { factory: () => '/assets/daffio/' }); |