Skip to content
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
Expand Up @@ -11,8 +11,6 @@ import {
throwError,
} from 'rxjs';

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

import { DocsResolver } from './docs-resolver.service';
import { DaffioDocsServiceInterface } from '../services/docs-service.interface';
import { DaffioDocsService } from '../services/docs.service';
Expand All @@ -25,7 +23,7 @@ describe('DocsResolver', () => {

const doc = new DaffioDocsFactory().create();
const stubDocService: DaffioDocsServiceInterface = {
get: (path: string): Observable<DaffDoc> => of(doc),
get: <T>(path: string): Observable<T> => of(<T>doc),
};

beforeEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions apps/daffio/src/app/docs/resolvers/docs-resolver.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import { DaffioDocsService } from '../services/docs.service';
})
export class DocsResolver<T extends DaffDoc = DaffDoc> {

constructor(private docService: DaffioDocsService<T>, private router: Router) { }
constructor(private docService: DaffioDocsService, private router: Router) { }

resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<T> {
return this.docService
//remove any route fragment and initial slash from the route.
.get(daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(state.url)))
.get<T>(daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(state.url)))
.pipe(
take(1),
catchError(() => {
Expand Down
4 changes: 2 additions & 2 deletions apps/daffio/src/app/docs/services/docs-service.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { Observable } from 'rxjs';

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

export interface DaffioDocsServiceInterface<T extends DaffDoc = DaffDoc> {
get(path: string): Observable<T>;
export interface DaffioDocsServiceInterface {
get<T extends DaffDoc = DaffDoc>(path: string): Observable<T>;
}
5 changes: 2 additions & 3 deletions apps/daffio/src/app/docs/services/docs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ import {
@Injectable({
providedIn: 'root',
})
export class DaffioDocsService<T extends DaffDoc = DaffDoc> implements DaffioDocsServiceInterface<T> {

export class DaffioDocsService implements DaffioDocsServiceInterface {
constructor(
@Inject(DaffioAssetFetchService) private fetchAsset: DaffioAssetFetchServiceInterface,
@Inject(DAFFIO_DOCS_PATH_TOKEN) private docsPath: string,
) {}

get(path: string): Observable<T> {
get<T extends DaffDoc = DaffDoc>(path: string): Observable<T> {
return this.fetchAsset.fetch<T>(`${this.docsPath}/${crossOsFilename(path)}.json`);
}
}