refactor(aio): move document path computation

Do the path computation before doing the cache look up.
This commit is contained in:
Peter Bacon Darwin 2017-03-04 16:24:09 +00:00 committed by Igor Minar
parent 66cc88c8a8
commit dd50922747
1 changed files with 5 additions and 5 deletions

View File

@ -29,14 +29,14 @@ export class DocumentService {
private getDocument(url: string) {
this.logger.log('getting document', url);
if ( !this.cache.has(url)) {
this.cache.set(url, this.fetchDocument(url));
const path = this.computePath(url);
if ( !this.cache.has(path)) {
this.cache.set(path, this.fetchDocument(path));
}
return this.cache.get(url);
return this.cache.get(path);
}
private fetchDocument(url: string) {
const path = this.computePath(url);
private fetchDocument(path: string) {
this.logger.log('fetching document from', path);
const subject = new AsyncSubject();
this.http