Skip to content

Commit 4ee3c2f

Browse files
committed
feat(daffio): move generic of docs service to method
1 parent f14761a commit 4ee3c2f

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

apps/daffio/src/app/docs/resolvers/docs-resolver.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import { DaffioDocsService } from '../services/docs.service';
2626
})
2727
export class DocsResolver<T extends DaffDoc = DaffDoc> {
2828

29-
constructor(private docService: DaffioDocsService<T>, private router: Router) { }
29+
constructor(private docService: DaffioDocsService, private router: Router) { }
3030

3131
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<T> {
3232
return this.docService
3333
//remove any route fragment and initial slash from the route.
34-
.get(daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(state.url)))
34+
.get<T>(daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(state.url)))
3535
.pipe(
3636
take(1),
3737
catchError(() => {

apps/daffio/src/app/docs/services/docs-service.interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { Observable } from 'rxjs';
22

33
import { DaffDoc } from '@daffodil/docs-utils';
44

5-
export interface DaffioDocsServiceInterface<T extends DaffDoc = DaffDoc> {
6-
get(path: string): Observable<T>;
5+
export interface DaffioDocsServiceInterface {
6+
get<T extends DaffDoc = DaffDoc>(path: string): Observable<T>;
77
}

apps/daffio/src/app/docs/services/docs.service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ import {
1919
@Injectable({
2020
providedIn: 'root',
2121
})
22-
export class DaffioDocsService<T extends DaffDoc = DaffDoc> implements DaffioDocsServiceInterface<T> {
23-
22+
export class DaffioDocsService implements DaffioDocsServiceInterface {
2423
constructor(
2524
@Inject(DaffioAssetFetchService) private fetchAsset: DaffioAssetFetchServiceInterface,
2625
@Inject(DAFFIO_DOCS_PATH_TOKEN) private docsPath: string,
2726
) {}
2827

29-
get(path: string): Observable<T> {
28+
get<T extends DaffDoc = DaffDoc>(path: string): Observable<T> {
3029
return this.fetchAsset.fetch<T>(`${this.docsPath}/${crossOsFilename(path)}.json`);
3130
}
3231
}

0 commit comments

Comments
 (0)