mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-26 18:43:43 +03:00
32 lines
707 B
TypeScript
32 lines
707 B
TypeScript
'use strict';
|
|
import { Injectable } from '@angular/core';
|
|
import { PlatformLocation } from '@angular/common';
|
|
|
|
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
|
import { SpecManager } from '../utils/spec-manager';
|
|
|
|
@Injectable()
|
|
export class Hash {
|
|
public value = new BehaviorSubject<string>('');
|
|
constructor(private specMgr: SpecManager, private location: PlatformLocation) {
|
|
this.bind();
|
|
|
|
this.specMgr.spec.subscribe((spec) => {
|
|
if (!spec) return;
|
|
setTimeout(() => {
|
|
this.value.next(this.hash);
|
|
});
|
|
});
|
|
}
|
|
|
|
get hash() {
|
|
return this.location.hash;
|
|
}
|
|
|
|
bind() {
|
|
this.location.onHashChange(() => {
|
|
this.value.next(this.hash);
|
|
});
|
|
}
|
|
}
|