Using OpModeLazyCell
OpModeLazyCell
and OpModeFreshCell
are both cells that use features from
both LazyCell
in Util and features from Dairy Core.
OpModeLazyCell
is a LazyCell that gets eagerly evaluated via a preInit hook.
This means that you can put hardware initialisation in an OpModeLazyCell
and
separate out your init phase, while its still safe to use the contents of the
cell at any point after init starts.
OpModeLazyCell
deregister
s after the OpMode runs, but OpModeFreshCell
does
not, so if you need your cell to be reinstantiated every OpMode then you can use
OpModeFreshCell
, which is exactly the same, but does not exhibit the automatic
deregister
ing behaviour.
This will be demonstrated when looking further at templating!
As with all Cells, OpModeLazyCell
and OpModeFreshCell
can be used for
delegation in Kotlin.