Skip to content

Commit

Permalink
feat(daffio): create injection tokens with factory (#3267)
Browse files Browse the repository at this point in the history
  • Loading branch information
griest024 authored Oct 14, 2024
1 parent 5ac537a commit 46c8e96
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
17 changes: 7 additions & 10 deletions apps/daffio/src/app/core/assets/fetch/service.interface.ts
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) });
9 changes: 5 additions & 4 deletions apps/daffio/src/app/docs/services/docs-path.token.ts
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/' });

0 comments on commit 46c8e96

Please sign in to comment.