Skip to content

Inline callbacks with one-time set function

Compare
Choose a tag to compare
@andycate andycate released this 01 Mar 03:55
· 44 commits to master since this release
e6401c7

This release adds functionality that allows the programmer to add a lambda function as a callback just once. Then, it is called whenever Dashboard.update() is called, and a variable change is present.
Example:

...
class Robot : TimedRobot(0.005) {
    ...
    fun robotInit() {
        ...
        Dashboard.addInlineListener("SOME_VARIABLE") {
            key: String, value: Any? ->
            println("$key : $value")
        }
        ...
    }
    ...
    fun robotPeriodic() {
        Dashboard.update() // Any callbacks will be called at this time
        ...
    }
    ...
}