src/app/services/consent.service.ts
Properties |
|
Methods |
constructor()
|
Defined in src/app/services/consent.service.ts:10
|
setConsent | ||||||
setConsent(value: Consent)
|
||||||
Defined in src/app/services/consent.service.ts:20
|
||||||
Parameters :
Returns :
void
|
unsetConsent |
unsetConsent()
|
Defined in src/app/services/consent.service.ts:27
|
Returns :
void
|
consent |
Type : Consent
|
Default value : 'not-set'
|
Defined in src/app/services/consent.service.ts:8
|
Readonly consentChange |
Default value : new ReplaySubject<Consent>(1)
|
Defined in src/app/services/consent.service.ts:10
|
import { Injectable, OnDestroy } from '@angular/core';
import { ReplaySubject } from 'rxjs';
export type Consent = 'not-set' | 'given' | 'rescinded';
@Injectable()
export class ConsentService implements OnDestroy {
consent: Consent = 'not-set';
readonly consentChange = new ReplaySubject<Consent>(1);
constructor() {
this.consentChange.next(this.consent);
}
ngOnDestroy(): void {
this.consentChange.complete();
}
setConsent(value: Consent): void {
if (this.consent !== value) {
this.consent = value;
this.consentChange.next(value);
}
}
unsetConsent(): void {
this.setConsent('not-set');
}
}