blob: 5b0a13de2ea2d2808c3d801c4d9af5bbc654d04d (
plain) (
blame)
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
|
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())
}
}
}
|