vw_handler_add_effect | R Documentation |
With a JavaScript handler, once you have calculated a value
based on the handler's arguments (e.g. name
, value
) you will
likely want to produce a side-effect based on that calculated value.
This function helps you do that.
vw_handler_add_effect(vw_handler, body_effect, ...)
vw_handler |
|
body_effect |
|
... |
additional named parameters to be interpolated into the text of the handler_body |
The calculation of a value is meant to be separate from the production of a side-effect. This way, the code for a side-effect can be used for any type of handler.
You are supplying the body_effect
to an effect-handler. This
takes a single argument, x
, representing the
calculated value. Doing this allows us to chain side-effects together;
be careful not to modify x
in any of the code you provide.
To see what side-effects are available in this package's handler-library,
call vw_handler_add_effect()
without any arguments. You may notice that
some of the effects, like "element_text"
, require additional parameters,
in this case, selector
.
Those parameters with a default value of NULL
require you to supply
a value; those with sensible defaults are optional.
To provide the parameters, call
vw_handler_add_effect()
with named arguments corresponding to the
names of the parameters. See the examples for details.
modified copy of vw_handler
vw_handler_signal()
# list all the available effect-handlers
vw_handler_add_effect()
# build a signal handler that prints some text,
# then the value, to the console
vw_handler_signal("value") %>%
vw_handler_add_effect("console", label = "signal value:")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.