From a526ab6996252ad6f1db55020bfeef4250b97699 Mon Sep 17 00:00:00 2001 From: lukecologne Date: Sat, 23 Nov 2024 18:50:17 +0100 Subject: [PATCH] refactor(fcu): modernize FCU avionics-framework code (#9544) --- .../src/FCU/Components/AfsDisplay.tsx | 78 ++++--- .../src/FCU/Components/EisDisplay.tsx | 139 ++++++------ .../src/FCU/Components/HdgDisplay.tsx | 141 ++++++------ .../src/FCU/Components/SpdDisplay.tsx | 151 +++++++------ .../src/FCU/Components/VerticalDisplay.tsx | 201 +++++++++--------- .../src/systems/instruments/src/FCU/FCU.tsx | 21 +- 6 files changed, 371 insertions(+), 360 deletions(-) diff --git a/fbw-a32nx/src/systems/instruments/src/FCU/Components/AfsDisplay.tsx b/fbw-a32nx/src/systems/instruments/src/FCU/Components/AfsDisplay.tsx index 2b67034f4eb..4a2063cc9b7 100644 --- a/fbw-a32nx/src/systems/instruments/src/FCU/Components/AfsDisplay.tsx +++ b/fbw-a32nx/src/systems/instruments/src/FCU/Components/AfsDisplay.tsx @@ -1,4 +1,14 @@ -import { ComponentProps, DisplayComponent, EventBus, FSComponent, Subject, VNode } from '@microsoft/msfs-sdk'; +import { + ComponentProps, + ConsumerSubject, + DisplayComponent, + EventBus, + FSComponent, + MappedSubject, + Subject, + SubscribableMapFunctions, + VNode, +} from '@microsoft/msfs-sdk'; import { FcuSimvars } from '../shared/FcuSimvarPublisher'; import { HdgDisplay } from './HdgDisplay'; import { SpdDisplay } from './SpdDisplay'; @@ -9,13 +19,20 @@ interface AfsDisplayProps extends ComponentProps { } export class AfsDisplay extends DisplayComponent { - private lightsTest = false; + private lightsTest = Subject.create(false); - private trkFpaMode = false; + private trkFpaMode = ConsumerSubject.create(null, false); - private trkFpaLabelSub = Subject.create(''); - - private hdgVsLabelSub = Subject.create(''); + private trkFpaLabelSub = MappedSubject.create( + ([trkFpa, lightsTest]) => trkFpa || lightsTest, + this.trkFpaMode, + this.lightsTest, + ); + private hdgVsLabelSub = MappedSubject.create( + ([trkFpa, lightsTest]) => !trkFpa || lightsTest, + this.trkFpaMode, + this.lightsTest, + ); public onAfterRender(node: VNode): void { super.onAfterRender(node); @@ -26,23 +43,10 @@ export class AfsDisplay extends DisplayComponent { .on('lightsTest') .whenChanged() .handle((value) => { - this.lightsTest = value === 0; - - this.handleLabels(); - }); - - sub - .on('afsDisplayTrkFpaMode') - .whenChanged() - .handle((value) => { - this.trkFpaMode = value; - this.handleLabels(); + this.lightsTest.set(value === 0); }); - } - private handleLabels() { - this.trkFpaLabelSub.set(this.trkFpaMode || this.lightsTest ? 'Active' : 'Inactive'); - this.hdgVsLabelSub.set(!this.trkFpaMode || this.lightsTest ? 'Active' : 'Inactive'); + this.trkFpaMode.setConsumer(sub.on('afsDisplayTrkFpaMode')); } public render(): VNode { @@ -53,19 +57,43 @@ export class AfsDisplay extends DisplayComponent { - + HDG - + TRK - + V/S - + FPA diff --git a/fbw-a32nx/src/systems/instruments/src/FCU/Components/EisDisplay.tsx b/fbw-a32nx/src/systems/instruments/src/FCU/Components/EisDisplay.tsx index 9ce004ae53e..ec6f1b9eefe 100644 --- a/fbw-a32nx/src/systems/instruments/src/FCU/Components/EisDisplay.tsx +++ b/fbw-a32nx/src/systems/instruments/src/FCU/Components/EisDisplay.tsx @@ -1,4 +1,13 @@ -import { ComponentProps, DisplayComponent, EventBus, FSComponent, Subject, VNode } from '@microsoft/msfs-sdk'; +import { + ComponentProps, + ConsumerSubject, + DisplayComponent, + EventBus, + FSComponent, + MappedSubject, + Subject, + VNode, +} from '@microsoft/msfs-sdk'; import { FcuSimvars } from '../shared/FcuSimvarPublisher'; interface EisDisplayProps extends ComponentProps { @@ -9,19 +18,62 @@ interface EisDisplayProps extends ComponentProps { } export class EisDisplay extends DisplayComponent { - private baroValueMode = 0; - - private baroValue = 0; - - private baroMode = 0; - - private lightsTest = false; - - private baroValueSub = Subject.create(''); - - private qnhLabelSub = Subject.create(''); - - private qfeLabelSub = Subject.create(''); + private baroValueMode = ConsumerSubject.create(null, 0); + + private baroValue = ConsumerSubject.create(null, 0); + + private baroMode = ConsumerSubject.create(null, 0); + + private lightsTest = Subject.create(false); + + private baroValueSub = MappedSubject.create( + ([lightsTest, baroValueMode, baroValue]) => { + if (lightsTest) { + return '88.88'; + } else if (baroValueMode === 0) { + return 'Std'; + } else if (baroValueMode === 1) { + return Math.round(baroValue).toString(); + } else { + return baroValue.toFixed(2); + } + }, + this.lightsTest, + this.baroValueMode, + this.baroValue, + ); + + private qnhLabelSub = MappedSubject.create( + ([lightsTest, baroMode]) => { + if (lightsTest) { + return 'Active'; + } else if (baroMode === 0) { + return 'Inactive'; + } else if (baroMode === 1) { + return 'Active'; + } else { + return 'Inactive'; + } + }, + this.lightsTest, + this.baroMode, + ); + + private qfeLabelSub = MappedSubject.create( + ([lightsTest, baroMode]) => { + if (lightsTest) { + return 'Active'; + } else if (baroMode === 0) { + return 'Inactive'; + } else if (baroMode === 1) { + return 'Inactive'; + } else { + return 'Active'; + } + }, + this.lightsTest, + this.baroMode, + ); public onAfterRender(node: VNode): void { super.onAfterRender(node); @@ -32,65 +84,14 @@ export class EisDisplay extends DisplayComponent { .on('lightsTest') .whenChanged() .handle((value) => { - this.lightsTest = value === 0; - - this.handleLabels(); - this.handleValue(); - }); - - sub - .on(`eisDisplay${this.props.isCaptSide ? 'Left' : 'Right'}BaroValueMode`) - .whenChanged() - .handle((newVal) => { - this.baroValueMode = newVal; - this.handleLabels(); - this.handleValue(); - }); - - sub - .on(`eisDisplay${this.props.isCaptSide ? 'Left' : 'Right'}BaroValue`) - .whenChanged() - .handle((newVal) => { - this.baroValue = newVal; - this.handleValue(); + this.lightsTest.set(value === 0); }); - sub - .on(`eisDisplay${this.props.isCaptSide ? 'Left' : 'Right'}BaroMode`) - .whenChanged() - .handle((newVal) => { - this.baroMode = newVal; - this.handleLabels(); - this.handleValue(); - }); - } + this.baroValueMode.setConsumer(sub.on(`eisDisplay${this.props.isCaptSide ? 'Left' : 'Right'}BaroValueMode`)); - private handleValue() { - if (this.lightsTest) { - this.baroValueSub.set('88.88'); - } else if (this.baroValueMode === 0) { - this.baroValueSub.set('Std'); - } else if (this.baroValueMode === 1) { - this.baroValueSub.set(Math.round(this.baroValue).toString()); - } else { - this.baroValueSub.set(this.baroValue.toFixed(2)); - } - } + this.baroValue.setConsumer(sub.on(`eisDisplay${this.props.isCaptSide ? 'Left' : 'Right'}BaroValue`)); - private handleLabels() { - if (this.lightsTest) { - this.qfeLabelSub.set('Active'); - this.qnhLabelSub.set('Active'); - } else if (this.baroMode === 0) { - this.qfeLabelSub.set('Inactive'); - this.qnhLabelSub.set('Inactive'); - } else if (this.baroMode === 1) { - this.qfeLabelSub.set('Inactive'); - this.qnhLabelSub.set('Active'); - } else { - this.qfeLabelSub.set('Active'); - this.qnhLabelSub.set('Inactive'); - } + this.baroMode.setConsumer(sub.on(`eisDisplay${this.props.isCaptSide ? 'Left' : 'Right'}BaroMode`)); } public render(): VNode { diff --git a/fbw-a32nx/src/systems/instruments/src/FCU/Components/HdgDisplay.tsx b/fbw-a32nx/src/systems/instruments/src/FCU/Components/HdgDisplay.tsx index 82739354168..dbf5a9952e5 100644 --- a/fbw-a32nx/src/systems/instruments/src/FCU/Components/HdgDisplay.tsx +++ b/fbw-a32nx/src/systems/instruments/src/FCU/Components/HdgDisplay.tsx @@ -1,24 +1,57 @@ -import { DisplayComponent, EventBus, FSComponent, Subject, VNode } from '@microsoft/msfs-sdk'; +import { + ConsumerSubject, + DisplayComponent, + EventBus, + FSComponent, + MappedSubject, + Subject, + SubscribableMapFunctions, + VNode, +} from '@microsoft/msfs-sdk'; import { FcuSimvars } from '../shared/FcuSimvarPublisher'; export class HdgDisplay extends DisplayComponent<{ x: number; y: number; bus: EventBus }> { - private value = 0; - - private dashes = false; - - private managed = false; - - private trkFpaMode = false; - - private lightsTest = false; - - private dotVisibilitySub = Subject.create(''); - - private hdgLabelSub = Subject.create(''); - - private trkLabelSub = Subject.create(''); - - private valueSub = Subject.create(''); + private value = ConsumerSubject.create(null, 0); + + private dashes = ConsumerSubject.create(null, false); + + private managed = ConsumerSubject.create(null, false); + + private trkFpaMode = ConsumerSubject.create(null, false); + + private lightsTest = Subject.create(false); + + private dotVisibilitySub = MappedSubject.create( + ([lightsTest, managed]) => (managed || lightsTest ? 'visible' : 'hidden'), + this.lightsTest, + this.managed, + ); + + private trkLabelSub = MappedSubject.create( + ([trkFpa, lightsTest]) => trkFpa || lightsTest, + this.trkFpaMode, + this.lightsTest, + ); + private hdgLabelSub = MappedSubject.create( + ([trkFpa, lightsTest]) => !trkFpa || lightsTest, + this.trkFpaMode, + this.lightsTest, + ); + + private valueSub = MappedSubject.create( + ([lightsTest, dashes, value]) => { + if (lightsTest) { + return '888'; + } else if (dashes) { + return '---'; + } else { + return Math.round(value).toString().padStart(3, '0'); + } + }, + this.lightsTest, + this.dashes, + this.value, + ); public onAfterRender(node: VNode): void { super.onAfterRender(node); @@ -29,73 +62,35 @@ export class HdgDisplay extends DisplayComponent<{ x: number; y: number; bus: Ev .on('lightsTest') .whenChanged() .handle((value) => { - this.lightsTest = value === 0; - - this.handleLabels(); - this.handleHdgDisplay(); - this.handleDot(); - }); - - sub - .on('afsDisplayTrkFpaMode') - .whenChanged() - .handle((value) => { - this.trkFpaMode = value; - - this.handleLabels(); - }); - - sub - .on('afsDisplayHdgTrkDashes') - .whenChanged() - .handle((value) => { - this.dashes = value; - this.handleHdgDisplay(); - }); - - sub - .on('afsDisplayHdgTrkValue') - .whenChanged() - .handle((value) => { - this.value = value; - this.handleHdgDisplay(); + this.lightsTest.set(value === 0); }); - sub - .on('afsDisplayHdgTrkManaged') - .whenChanged() - .handle((value) => { - this.managed = value; - this.handleDot(); - }); - } + this.trkFpaMode.setConsumer(sub.on('afsDisplayTrkFpaMode')); - private handleHdgDisplay() { - if (this.lightsTest) { - this.valueSub.set('888'); - } else if (this.dashes) { - this.valueSub.set('---'); - } else { - this.valueSub.set(Math.round(this.value).toString().padStart(3, '0')); - } - } + this.dashes.setConsumer(sub.on('afsDisplayHdgTrkDashes')); - private handleLabels() { - this.trkLabelSub.set(this.trkFpaMode || this.lightsTest ? 'Active' : 'Inactive'); - this.hdgLabelSub.set(!this.trkFpaMode || this.lightsTest ? 'Active' : 'Inactive'); - } + this.value.setConsumer(sub.on('afsDisplayHdgTrkValue')); - private handleDot() { - this.dotVisibilitySub.set(this.managed || this.lightsTest ? 'visible' : 'hidden'); + this.managed.setConsumer(sub.on('afsDisplayHdgTrkManaged')); } public render(): VNode { return ( - + HDG - + TRK diff --git a/fbw-a32nx/src/systems/instruments/src/FCU/Components/SpdDisplay.tsx b/fbw-a32nx/src/systems/instruments/src/FCU/Components/SpdDisplay.tsx index 6d4c951e519..374d5dc9ac9 100644 --- a/fbw-a32nx/src/systems/instruments/src/FCU/Components/SpdDisplay.tsx +++ b/fbw-a32nx/src/systems/instruments/src/FCU/Components/SpdDisplay.tsx @@ -1,24 +1,62 @@ -import { DisplayComponent, EventBus, FSComponent, Subject, VNode } from '@microsoft/msfs-sdk'; +import { + ConsumerSubject, + DisplayComponent, + EventBus, + FSComponent, + MappedSubject, + Subject, + SubscribableMapFunctions, + VNode, +} from '@microsoft/msfs-sdk'; import { FcuSimvars } from '../shared/FcuSimvarPublisher'; export class SpdDisplay extends DisplayComponent<{ x: number; y: number; bus: EventBus }> { - private value = 0; - - private dashes = false; - - private managed = false; - - private machActive = false; - - private lightsTest = false; - - private dotVisibilitySub = Subject.create(''); - - private spdLabelSub = Subject.create(''); - - private machLabelSub = Subject.create(''); - - private valueSub = Subject.create(''); + private value = ConsumerSubject.create(null, 0); + + private dashes = ConsumerSubject.create(null, false); + + private managed = ConsumerSubject.create(null, false); + + private machActive = ConsumerSubject.create(null, false); + + private lightsTest = Subject.create(false); + + private dotVisibilitySub = MappedSubject.create( + ([lightsTest, managed]) => (managed || lightsTest ? 'visible' : 'hidden'), + this.lightsTest, + this.managed, + ); + + private spdLabelSub = MappedSubject.create( + ([machActive, lightsTest]) => !machActive || lightsTest, + this.machActive, + this.lightsTest, + ); + private machLabelSub = MappedSubject.create( + ([machActive, lightsTest]) => machActive || lightsTest, + this.machActive, + this.lightsTest, + ); + + private valueSub = MappedSubject.create( + ([lightsTest, dashes, value, machActive]) => { + if (lightsTest) { + return '8.88'; + } else if (machActive && dashes) { + return '-.--'; + } else if (machActive && !dashes) { + return value.toFixed(2); + } else if (dashes) { + return '---'; + } else { + return Math.round(value).toString().padStart(3, '0'); + } + }, + this.lightsTest, + this.dashes, + this.value, + this.machActive, + ); public onAfterRender(node: VNode): void { super.onAfterRender(node); @@ -29,78 +67,35 @@ export class SpdDisplay extends DisplayComponent<{ x: number; y: number; bus: Ev .on('lightsTest') .whenChanged() .handle((value) => { - this.lightsTest = value === 0; - - this.handleLabels(); - this.handleSpeedDisplay(); - this.handleDot(); - }); - - sub - .on('afsDisplayMachMode') - .whenChanged() - .handle((value) => { - this.machActive = value; - - this.handleSpeedDisplay(); - this.handleLabels(); - }); - - sub - .on('afsDisplaySpdMachDashes') - .whenChanged() - .handle((value) => { - this.dashes = value; - this.handleSpeedDisplay(); - }); - - sub - .on('afsDisplaySpdMachValue') - .whenChanged() - .handle((value) => { - this.value = value; - this.handleSpeedDisplay(); + this.lightsTest.set(value === 0); }); - sub - .on('afsDisplaySpdMachManaged') - .whenChanged() - .handle((value) => { - this.managed = value; - this.handleDot(); - }); - } + this.machActive.setConsumer(sub.on('afsDisplayMachMode')); - private handleSpeedDisplay() { - if (this.lightsTest) { - this.valueSub.set('8.88'); - } else if (this.machActive && this.dashes) { - this.valueSub.set('-.--'); - } else if (this.machActive && !this.dashes) { - this.valueSub.set(this.value.toFixed(2)); - } else if (this.dashes) { - this.valueSub.set('---'); - } else { - this.valueSub.set(Math.round(this.value).toString().padStart(3, '0')); - } - } + this.dashes.setConsumer(sub.on('afsDisplaySpdMachDashes')); - private handleLabels() { - this.machLabelSub.set(this.machActive || this.lightsTest ? 'Active' : 'Inactive'); - this.spdLabelSub.set(!this.machActive || this.lightsTest ? 'Active' : 'Inactive'); - } + this.value.setConsumer(sub.on('afsDisplaySpdMachValue')); - private handleDot() { - this.dotVisibilitySub.set(this.managed || this.lightsTest ? 'visible' : 'hidden'); + this.managed.setConsumer(sub.on('afsDisplaySpdMachManaged')); } public render(): VNode { return ( - + SPD - + MACH diff --git a/fbw-a32nx/src/systems/instruments/src/FCU/Components/VerticalDisplay.tsx b/fbw-a32nx/src/systems/instruments/src/FCU/Components/VerticalDisplay.tsx index 955bd5a0c72..51bd14cc1f1 100644 --- a/fbw-a32nx/src/systems/instruments/src/FCU/Components/VerticalDisplay.tsx +++ b/fbw-a32nx/src/systems/instruments/src/FCU/Components/VerticalDisplay.tsx @@ -1,28 +1,81 @@ -import { DisplayComponent, EventBus, FSComponent, Subject, VNode } from '@microsoft/msfs-sdk'; +import { + ConsumerSubject, + DisplayComponent, + EventBus, + FSComponent, + MappedSubject, + Subject, + SubscribableMapFunctions, + VNode, +} from '@microsoft/msfs-sdk'; import { FcuSimvars } from '../shared/FcuSimvarPublisher'; export class VerticalDisplay extends DisplayComponent<{ x: number; y: number; bus: EventBus }> { - private altValue = 0; - - private vsValue = 0; - - private vsDashes = false; - - private trkFpaMode = false; - - private managed = false; - - private lightsTest = false; - - private dotVisibilitySub = Subject.create(''); - - private vsLabelSub = Subject.create(''); - - private fpaLabelSub = Subject.create(''); - - private altValueSub = Subject.create(''); - - private vsValueSub = Subject.create(''); + private altValue = ConsumerSubject.create(null, 0); + + private vsValue = ConsumerSubject.create(null, 0); + + private vsDashes = ConsumerSubject.create(null, false); + + private trkFpaMode = ConsumerSubject.create(null, false); + + private managed = ConsumerSubject.create(null, false); + + private lightsTest = Subject.create(false); + + private dotVisibilitySub = MappedSubject.create( + ([lightsTest, managed]) => (managed || lightsTest ? 'visible' : 'hidden'), + this.lightsTest, + this.managed, + ); + + private fpaLabelSub = MappedSubject.create( + ([trkFpa, lightsTest]) => trkFpa || lightsTest, + this.trkFpaMode, + this.lightsTest, + ); + private vsLabelSub = MappedSubject.create( + ([trkFpa, lightsTest]) => !trkFpa || lightsTest, + this.trkFpaMode, + this.lightsTest, + ); + + private altValueSub = MappedSubject.create( + ([lightsTest, altValue]) => { + if (lightsTest) { + return '88888'; + } else { + return Math.round(altValue).toString().padStart(5, '0'); + } + }, + this.lightsTest, + this.altValue, + ); + + private vsValueSub = MappedSubject.create( + ([lightsTest, vsDashes, vsValue, trkFpaMode]) => { + const sign = Math.sign(vsValue) >= 0 ? '+' : '~'; + const absValue = Math.abs(vsValue); + + if (lightsTest) { + return '+8.888'; + } else if (trkFpaMode && vsDashes) { + return '~-.-'; + } else if (trkFpaMode && !vsDashes) { + return `${sign}${absValue.toFixed(1)}`; + } else if (vsDashes) { + return '~----'; + } else { + return `${sign}${Math.floor(absValue * 0.01) + .toString() + .padStart(2, '0')}oo`; + } + }, + this.lightsTest, + this.vsDashes, + this.vsValue, + this.trkFpaMode, + ); public onAfterRender(node: VNode): void { super.onAfterRender(node); @@ -33,94 +86,18 @@ export class VerticalDisplay extends DisplayComponent<{ x: number; y: number; bu .on('lightsTest') .whenChanged() .handle((value) => { - this.lightsTest = value === 0; - - this.handleLabels(); - this.handleVsFpaDisplay(); - this.handleAltDisplay(); - this.handleDot(); + this.lightsTest.set(value === 0); }); - sub - .on('afsDisplayTrkFpaMode') - .whenChanged() - .handle((value) => { - this.trkFpaMode = value; + this.trkFpaMode.setConsumer(sub.on('afsDisplayTrkFpaMode')); - this.handleVsFpaDisplay(); - this.handleLabels(); - }); + this.vsDashes.setConsumer(sub.on('afsDisplayVsFpaDashes')); - sub - .on('afsDisplayVsFpaDashes') - .whenChanged() - .handle((value) => { - this.vsDashes = value; - this.handleVsFpaDisplay(); - }); + this.vsValue.setConsumer(sub.on('afsDisplayVsFpaValue')); - sub - .on('afsDisplayVsFpaValue') - .whenChanged() - .handle((value) => { - this.vsValue = value; - this.handleVsFpaDisplay(); - }); - - sub - .on('afsDisplayAltValue') - .whenChanged() - .handle((value) => { - this.altValue = value; - this.handleAltDisplay(); - }); - - sub - .on('afsDisplayLvlChManaged') - .whenChanged() - .handle((value) => { - this.managed = value; - - this.handleDot(); - }); - } - - private handleAltDisplay() { - if (this.lightsTest) { - this.altValueSub.set('88888'); - } else { - this.altValueSub.set(Math.round(this.altValue).toString().padStart(5, '0')); - } - } - - private handleVsFpaDisplay() { - const sign = Math.sign(this.vsValue) >= 0 ? '+' : '~'; - const absValue = Math.abs(this.vsValue); - - if (this.lightsTest) { - this.vsValueSub.set('+8.888'); - } else if (this.trkFpaMode && this.vsDashes) { - this.vsValueSub.set('~-.-'); - } else if (this.trkFpaMode && !this.vsDashes) { - this.vsValueSub.set(`${sign}${absValue.toFixed(1)}`); - } else if (this.vsDashes) { - this.vsValueSub.set('~----'); - } else { - this.vsValueSub.set( - `${sign}${Math.floor(absValue * 0.01) - .toString() - .padStart(2, '0')}oo`, - ); - } - } - - private handleLabels() { - this.fpaLabelSub.set(this.trkFpaMode || this.lightsTest ? 'Active' : 'Inactive'); - this.vsLabelSub.set(!this.trkFpaMode || this.lightsTest ? 'Active' : 'Inactive'); - } + this.altValue.setConsumer(sub.on('afsDisplayAltValue')); - private handleDot() { - this.dotVisibilitySub.set(this.managed || this.lightsTest ? 'visible' : 'hidden'); + this.managed.setConsumer(sub.on('afsDisplayLvlChManaged')); } public render(): VNode { @@ -136,10 +113,22 @@ export class VerticalDisplay extends DisplayComponent<{ x: number; y: number; bu - + V/S - + FPA diff --git a/fbw-a32nx/src/systems/instruments/src/FCU/FCU.tsx b/fbw-a32nx/src/systems/instruments/src/FCU/FCU.tsx index 0098aea5f53..f3e7dea73e4 100644 --- a/fbw-a32nx/src/systems/instruments/src/FCU/FCU.tsx +++ b/fbw-a32nx/src/systems/instruments/src/FCU/FCU.tsx @@ -1,4 +1,12 @@ -import { ComponentProps, DisplayComponent, EventBus, FSComponent, Subject, VNode } from '@microsoft/msfs-sdk'; +import { + ComponentProps, + ConsumerSubject, + DisplayComponent, + EventBus, + FSComponent, + SubscribableMapFunctions, + VNode, +} from '@microsoft/msfs-sdk'; import { EisDisplay } from 'instruments/src/FCU/Components/EisDisplay'; import { AfsDisplay } from 'instruments/src/FCU/Components/AfsDisplay'; @@ -10,19 +18,14 @@ interface FCUProps extends ComponentProps { } export class FCUComponent extends DisplayComponent { - private visSub = Subject.create<'' | 'Hide'>('Hide'); + private fcuHealthy = ConsumerSubject.create(null, false); onAfterRender(node: VNode): void { super.onAfterRender(node); const sub = this.props.bus.getSubscriber(); - sub - .on('fcuHealthy') - .whenChanged() - .handle((value) => { - this.visSub.set(value ? '' : 'Hide'); - }); + this.fcuHealthy.setConsumer(sub.on('fcuHealthy')); } render(): VNode { @@ -30,7 +33,7 @@ export class FCUComponent extends DisplayComponent { <> - +