EasyStack Docs

Decorators

Decorators

#4. Decorators

Decorators are called on any command to modify the way it works and return a new command from it, leaving the original unmodified.

Using decorators functionality is similar to the Group Commands.

DecoratorClass behind itDescription
withTimeout(ms)TimeoutCommandActs like a timer, ends the command after ms. If the time cut it short, the inner command gets end(true).
until(cond)UntilCommandEnds when the condition is true. The inner command gets end(true) if it had not finished on its own.
andThen(cmds...)SequentialCommandGroupRuns this command, then the others in order.
beforeStarting(cmds...)SequentialCommandGroupRuns the others first, then this command.
andThenRun(Runnable)InstantCommandShortcut for andThen(new InstantCommand(...)).
afterDelay(ms)DelayedCommandWaits ms, then runs the command.
alongWith(cmds...)ParallelCommandGroupParallel; finishes when all finish.
raceWith(cmds...)ParallelRaceGroupParallel; finishes when any finishes.
deadlineWith(cmds...)ParallelDeadlineGroupParallel; finishes when this command finishes.
repeatedly()RepeatCommandRepeats forever.
repeat(n)RepeatCommandRepeats n times.
perpetually()PerpetualCommandIgnores the inner isFinished(); runs until cancelled.
finallyDo(Consumer<Boolean>)FinallyCommandRuns an action at the end, after the inner end(). The boolean says whether it was interrupted.
onlyIf(cond)ConditionalCommandRuns only if the condition is true at start; otherwise finishes at once.
unless(cond)ConditionalCommandThe opposite of onlyIf.
withRequirements(subs...)AddRequirementsCommandAdds subsystems to the command's requirements.
asProxy()ProxyCommandSee below.
Java
asProxy()

ProxyCommand schedules the command on the scheduler (outside the group) and waits for it to finish. It does not inherit the command's requirements, so the group that contains it is not blocked by those subsystems. If the proxy is interrupted, it cancels the command it started. Use it when part of a sequence must outlive the group's other requirements.

#How they work

Decorators that wrap a single command (withTimeout, until, perpetually, finallyDo, withRequirements) extend WrapperCommand. It delegates initialize, execute, end, isFinished and getRequirements to the inner command, and each decorator overrides only what it changes. A wrapper's requirements are the inner command's, except withRequirements, which extends them.

#Beginner Shortcut

Just starting? A Routine writes the same sequence as a simple list of steps, with no classes to remember. See the Routine tab at the beginning of Commands.

Last updated 2026-11-16

EasyStack - FTC Java library

This site records page views of visitors to understand how the documentation is used. Nothing is sold or shared with third parties.