Skip to content

Inline Callbacks

Compare
Choose a tag to compare
@andycate andycate released this 28 Feb 05:40
· 47 commits to master since this release
b5d4057

This update adds support for inline callbacks. These are really useful for streamlining dashboard integration. See the usage examples below:

Robot.kt

...
class Robot : TimedRobot(0.005) {
    ...
    fun robotPeriodic() {
        Dashboard.update()
        ...
    }
    ...
    fun teleopPeriodic() {
        ...
        Dashboard.runIfUpdate("SOME_VARIABLE") {
            key: String, value: Any? ->
            println("$key : $value")
        }
        ...
    }
    ...
}

Even though the function runIfUpdate is being called periodically, the lambda only gets called whenever SOME_VARIABLE is updated on the dashboard web page. This functionality only works if the Dashboard.update() function is called inside the robotPeriodic function.