Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 | 17x 17x 17x 17x 15x 15x 36x 12x 24x 12x 12x 5x 6x 12x | import { DestroyRef, Pipe, PipeTransform, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Subscription } from 'rxjs';
import { AppFacade } from 'ish-core/facades/app.facade';
/**
* Pipe
*
* Used on a string, this pipe will return the corresponding server setting by checking the general/serverConfig store.
* If it is set, the Pipe will return a truthy value.
*
* @example
* <example *ngIf="'services.ABC.runnable' | ishServerSetting"> ...</example>
*/
@Pipe({ name: 'ishServerSetting', pure: false })
export class ServerSettingPipe implements PipeTransform {
private returnValue: unknown;
private destroyRef = inject(DestroyRef);
private sub: Subscription;
constructor(private appFacade: AppFacade) {}
transform(path: string) {
if (path === 'always') {
return true;
} else if (path === 'never') {
return false;
} else {
if (!this.sub) {
this.sub = this.appFacade
.serverSetting$(path)
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(value => {
this.returnValue = value;
});
}
return this.returnValue;
}
}
}
|