make_spinner | R Documentation |
Create a spinner
make_spinner(
which = NULL,
stream = "auto",
template = "{spin}",
static = c("dots", "print", "print_line", "silent")
)
which |
The name of the chosen spinner. If |
stream |
The stream to use for the spinner. Typically this is
standard error, or maybe the standard output stream.
It can also be a string, one of |
template |
A template string, that will contain the spinner. The
spinner itself will be substituted for |
static |
What to do if the terminal does not support dynamic displays:
|
A cli_spinner
object, which is a list of functions. See
its methods below.
cli_spinner
methods:
$spin()
: output the next frame of the spinner.
$finish()
: terminate the spinner. Depending on terminal capabilities
this removes the spinner from the screen. Spinners can be reused,
you can start calling the $spin()
method again.
All methods return the spinner object itself, invisibly.
The spinner is automatically throttled to its ideal update frequency.
sp1 <- make_spinner() fun_with_spinner <- function() { lapply(1:100, function(x) { sp1$spin(); Sys.sleep(0.05) }) sp1$finish() } ansi_with_hidden_cursor(fun_with_spinner())
sp2 <- make_spinner(template = "Computing {spin}") fun_with_spinner2 <- function() { lapply(1:100, function(x) { sp2$spin(); Sys.sleep(0.05) }) sp2$finish() } ansi_with_hidden_cursor(fun_with_spinner2())
sp3 <- make_spinner("simpleDotsScrolling", template = "Downloading {spin}") fun_with_spinner3 <- function() { lapply(1:100, function(x) { sp3$spin(); Sys.sleep(0.05) }) sp3$finish() } ansi_with_hidden_cursor(fun_with_spinner3())
Other spinners:
demo_spinners()
,
get_spinner()
,
list_spinners()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.