aboutsummaryrefslogtreecommitdiff
path: root/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Instrument.scala
diff options
context:
space:
mode:
Diffstat (limited to 'vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Instrument.scala')
-rw-r--r--vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Instrument.scala28
1 files changed, 28 insertions, 0 deletions
diff --git a/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Instrument.scala b/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Instrument.scala
new file mode 100644
index 0000000..5b0a13d
--- /dev/null
+++ b/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Instrument.scala
@@ -0,0 +1,28 @@
+package vfd.dashboard.ui.instruments
+
+import rx._
+import org.scalajs.dom.html
+
+/** Common trait to all flight instruments. */
+trait Instrument[A] {
+
+ /** Initial value. */
+ val initial: A
+
+ /** Current value that is displayed in the instrument. */
+ val value: Var[A] = Var(initial)
+
+ /** HTML element that contains the rendered instrument */
+ val element: html.Element
+
+ /** Performs the actual UI update of this instrument. */
+ protected def update(newValue: A): Unit
+
+ /** Call when instrument has finished setting up its UI. */
+ protected def ready() = {
+ Obs(value, skipInitial = true) {
+ update(value())
+ }
+ }
+
+} \ No newline at end of file