mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-24 17:43:45 +03:00
28 lines
533 B
TypeScript
28 lines
533 B
TypeScript
'use strict';
|
|
import { Injectable } from '@angular/core';
|
|
import { PlatformLocation } from '@angular/common';
|
|
|
|
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
|
|
|
@Injectable()
|
|
export class Hash {
|
|
public value = new BehaviorSubject<string | null>(null);
|
|
constructor(private location: PlatformLocation) {
|
|
this.bind();
|
|
}
|
|
|
|
start() {
|
|
this.value.next(this.hash);
|
|
}
|
|
|
|
get hash() {
|
|
return this.location.hash;
|
|
}
|
|
|
|
bind() {
|
|
this.location.onHashChange(() => {
|
|
this.value.next(this.hash);
|
|
});
|
|
}
|
|
}
|