These bricks encapsulate n
stops: wait for a sequence of n
signals. wait_until
also traps and untraps the required signals.
Arguments
- .trj
the trajectory object.
- n
number of
wait
activities to chain.- signals
signal or list of signals, accepts either a string, a list of strings or a callable object (a function) which must return a string or a list of strings.
Value
wait_n
returns n
times wait
.
wait_until
also adds trap
and
untrap
at the beginning and end, respectively,
of the chain of wait
s (see examples below).
Examples
## These are equivalent:
trajectory() %>%
wait_n(3)
#> trajectory: anonymous, 3 activities
#> { Activity: Wait | }
#> { Activity: Wait | }
#> { Activity: Wait | }
trajectory() %>%
wait() %>%
wait() %>%
wait()
#> trajectory: anonymous, 3 activities
#> { Activity: Wait | }
#> { Activity: Wait | }
#> { Activity: Wait | }
## These are equivalent:
trajectory() %>%
wait_until("green")
#> trajectory: anonymous, 3 activities
#> { Activity: Trap | signals: [green] }
#> { Activity: Wait | }
#> { Activity: UnTrap | signals: [green] }
trajectory() %>%
trap("green") %>%
wait() %>%
untrap("green")
#> trajectory: anonymous, 3 activities
#> { Activity: Trap | signals: [green] }
#> { Activity: Wait | }
#> { Activity: UnTrap | signals: [green] }
## These are equivalent:
trajectory() %>%
wait_until(c("one", "another"), 2)
#> trajectory: anonymous, 4 activities
#> { Activity: Trap | signals: [one, another] }
#> { Activity: Wait | }
#> { Activity: Wait | }
#> { Activity: UnTrap | signals: [one, another] }
trajectory() %>%
trap(c("one", "another")) %>%
wait() %>%
wait() %>%
untrap(c("one", "another"))
#> trajectory: anonymous, 4 activities
#> { Activity: Trap | signals: [one, another] }
#> { Activity: Wait | }
#> { Activity: Wait | }
#> { Activity: UnTrap | signals: [one, another] }