Description Usage Arguments Value See Also Examples
Create S3 Generic Functions that Respects RAVE Context
1 | rave_context_generics(fun_name, args = alist(), env = parent.frame())
|
fun_name |
generic function name |
args |
list of arguments to the function. Use |
env |
in which environment the function is declared. |
A generic function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # Make a generic function that reacts under different contexts
# The goal is to ask user a comple question. Under debug mode,
# Ignore the question and always answer "Yes"
ask_for_input <- rave_context_generics(
'ask_for_input', args = alist(msg =, ...=))
# write default action. Since under default context, shiny is not running
ask_for_input.default <- function(msg, ...){
utils::askYesNo(msg)
}
ask_for_input.rave_module_debug <- function(msg, ...){
# Do not prompt questions and always answer yes
return(TRUE)
}
if(interactive()){
rave_context('default')
# will prompt for answer
ask_for_input('Answer yes or no')
}
# When debugging modules
rave_context('rave_module_debug', package = 'base')
ask_for_input('Answer yes or no') # always returns TRUE
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.