API

abstract class API

An API is shared code used by opmodes.

An API needs to be initialized with the init function before it can be used. In general, APIs should not have side-effects unless one of their functions is called. init should only be called once per opmode.

If an API requires methods only provided by a LinearOpMode, it must override isLinear and set it to true. It can then access the linearOpMode property, which is like opMode but casted to the LinearOpMode type.

An API can specify that it depends on another API by overriding the dependencies function and returning a Set of all the APIs it requires. These dependencies will be checked at runtime. It is additionally recommended to document in the comments what APIs your API depends on.

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open val isLinear: Boolean = false

Specifies whether this API requires a LinearOpMode to function.

Functions

Link copied to clipboard
open fun dependencies(): Set<API>

A function that returns a Set of all other APIs it depends on to function.

Link copied to clipboard
open fun init(opMode: OpMode)

Initializes the API to use the given opMode.