beep_with {catchr}R Documentation

Play short sounds

Description

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.

Usage

beep_with(beepr_sound)

Arguments

beepr_sound

A character string or number specifying the sound to be played. See the sound argument in beepr::beep() documentation.

See Also

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.

Examples

warning_in_middle <- function() {
  Sys.sleep(2)
  message("It's time!")
  Sys.sleep(2)
  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))
}

[Package catchr version 0.2.3 Index]