There are two types of handlers defined in this package's handler-library.
To see the handlers that are defined for each, call the function
without any arguments:
vw_handler_signal()
vw_handler_data()
vw_handler_event()
With a JavaScript handler, you are trying to do two types of things:
Let's look at a concrete example.
A signal handler
will take arguments name
and value
. Let's say that we want to
return the value. We could do this two ways:
In the list above, the two calls do exactly the same thing, they build a
JavaScript function that returns the value
provided by whatever is calling
the signal-handler. This will be a valid signal-handler, however, we will
likely want a signal-handler to do something with that value, which is
why we may wish to add a side-effect.
Let's say we want the handler to print the value to the JavaScript console.
We would create the signal-handler, then add an effect to print the result
to the console.
vw_handler_signal("value") %>% vw_handler_add_effect("console")
We can add as many effects as we like; for more information,
please see the documentation for vw_handler_add_effect()
.
Please be aware that these functions do not check for the correctness
of JavaScript code you supply - any errors you make will not be apparent
until your visualization is rendered in a browser.
One last note, if body_value
is already a vw_handler
, these functions
are no-ops; they will return the body_value
unchanged.