Description Usage Arguments See Also Examples
View source: R/make-handlers.R
If you have the beepr package installed, catchr can use it to play sounds when certain conditions are being handled with beep_with()
, similar to how beep
works. But unlike beep
and most catchr functions or special reserved terms, beep_with()
is meant to be used as a user-defined function in a plan. It is particularly useful for when you're working with futures
and busy doing something else while code is running in the background, or when you're working in a different window and want something to grab your attention.
beep_with
can be used at the "top" level of a plan, since it returns a function (which is required custom input for a catchr plan) that will play the beeping sound you've specified.
1 | beep_with(beepr_sound)
|
beepr_sound |
A character string or number specifying the sound to be played. See the |
the beep special term, which will play the default beep; user_exit()
and exit_with()
for parallel functions for the exit special term, and user_display()
and display_with()
for parallel functions for the display special term.
1 2 3 4 5 6 7 8 9 10 11 12 | warning_in_middle <- function() {
message("It's time!")
Sys.sleep(1)
invisible("done")
}
if (requireNamespace("beepr", quietly = TRUE) == TRUE) {
catch_expr(warning_in_middle(),
message = c(beep_with(2), display, muffle))
# Or you can just use the default sound with "beep":
# catch_expr(warning_in_middle(), message = c(beep, display, muffle))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.