Skip to content

Commit

Permalink
refactor(ng-universal-express): icon loader log errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vmasek committed Aug 14, 2023
1 parent 0435897 commit 6435719
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions projects/ng-universal-express/src/app/icon-load.ssr.strategy.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { Injectable } from '@angular/core';
import { SvgLoadStrategy } from '@push-based/ngx-fast-svg';
import { readFileSync } from 'node:fs';
import { readFile } from 'node:fs';
import { resolve } from 'node:path';
import { Observable, of } from 'rxjs';
import { Observable } from 'rxjs';

@Injectable()
export class IconLoadStrategySsr implements SvgLoadStrategy {
load(url: string): Observable<string> {
return of(readFileSync(resolve(url), 'utf8'));
return new Observable<string>((observer) => {
readFile(resolve(url), { encoding: 'utf8' }, (error, data) => {
if (error) {
observer.error(error);
} else {
observer.next(data);
}
});
});
}
}

0 comments on commit 6435719

Please sign in to comment.