diff options
author | Jakob Odersky <jakob@odersky.com> | 2016-02-24 20:29:30 -0800 |
---|---|---|
committer | Jakob Odersky <jakob@odersky.com> | 2016-02-24 20:31:14 -0800 |
commit | a41de68066007852d7d3dbf019d75b4caf7463ad (patch) | |
tree | b4446408291c9f179e1c270a561523023ac6a105 /mavigator-cockpit/src/main/scala/mavigator/dashboard/ui/instruments/Instrument.scala | |
parent | 245faaf1e2ff4d0fbda292dbb35f4b49426d4380 (diff) | |
download | mavigator-a41de68066007852d7d3dbf019d75b4caf7463ad.tar.gz mavigator-a41de68066007852d7d3dbf019d75b4caf7463ad.tar.bz2 mavigator-a41de68066007852d7d3dbf019d75b4caf7463ad.zip |
Major refactorings
Diffstat (limited to 'mavigator-cockpit/src/main/scala/mavigator/dashboard/ui/instruments/Instrument.scala')
-rw-r--r-- | mavigator-cockpit/src/main/scala/mavigator/dashboard/ui/instruments/Instrument.scala | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mavigator-cockpit/src/main/scala/mavigator/dashboard/ui/instruments/Instrument.scala b/mavigator-cockpit/src/main/scala/mavigator/dashboard/ui/instruments/Instrument.scala new file mode 100644 index 0000000..61f240c --- /dev/null +++ b/mavigator-cockpit/src/main/scala/mavigator/dashboard/ui/instruments/Instrument.scala @@ -0,0 +1,25 @@ +package mavigator.dashboard.ui.instruments + +import rx._ +import org.scalajs.dom.html + +/** Common trait to all flight instruments. */ +trait Instrument[A] { + + /** Current value that is displayed in the instrument. */ + val value: Rx[A] + + /** 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()) + } + } + +} |