-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbreadcrumb.component.ts
46 lines (42 loc) · 1.63 KB
/
breadcrumb.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import type { OnDestroy } from '@angular/core';
import { Component, ChangeDetectionStrategy } from '@angular/core';
import { CacheClientService } from '@core/cache-client/cache-client.service';
import { ServiceWorkerService } from '@core/service-worker/service-worker.service';
import { Breakpoints } from '@core/utility/window-values/breakpoints';
import { Destroyed } from '@shared/utility/classes/destroyed';
import { ReplaySubject } from 'rxjs';
import { BreadcrumbsService } from '../breadcrumbs.service';
@Component({
selector: 'app-breadcrumb',
templateUrl: './breadcrumb.component.html',
styleUrls: ['./breadcrumb.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BreadcrumbComponent extends Destroyed implements OnDestroy {
public readonly synchronizing$ = new ReplaySubject<boolean>(1);
// To use it in template
public breakpoints = Breakpoints;
constructor(
public readonly breadcrumbsService: BreadcrumbsService,
private readonly cacheClientService: CacheClientService,
private readonly serviceWorkerService: ServiceWorkerService
) {
super();
}
public syncCache() {
this.synchronizing$.next(true);
this.serviceWorkerService.checkForUpdate();
this.cacheClientService
.renewAll()
.catch((error) => {
this.synchronizing$.next(false);
errors.error({ error });
})
.finally(() =>
setTimeout(() => this.synchronizing$.next(false), 1000)
);
}
ngOnDestroy() {
this.destroyed.next(undefined);
}
}