golem::add_js_handler("name")
or add
$( document ).ready(function() {
Shiny.addCustomMessageHandler('fun', function(arg) {
})
});
In inst/app/www/handler.js
In R/app_ui.R
:
golem_add_external_resources <- function(){
addResourcePath(
'www', system.file('app/www', package = 'nineties')
)
tags$head(
golem::activate_js(),
golem::favicon(),
tags$script(src="www/handlers.js")
)
}
From the server side:
session$sendCustomMessage("fun", arg)
Good practice
$( document ).ready(function() {
Shiny.addCustomMessageHandler('fun', function(arg) {
arg.this + arg.that
})
});
Call them with
session$sendCustomMessage(
"fun",
list(
this = 40,
that = 42
)
)
notifyjs
is an open source JavaScript library designed to create custom notification boxes, released under the MIT License.
Notify.js is a jQuery plugin to provide simple yet fully customisable notifications.
https://notifyjs.jpillora.com/
JS available at: https://rawgit.com/notifyjs/notifyjs/master/dist/notify.js
Bring notifyjs
to Shiny
- Should go into
app/inst/www
- Link the script to the app in
R/app_ui.R
, in thegolem_add_external_resources
Use a
tags$script
or create anhtmlDependency
See "Custom Styling Guide" at https://notifyjs.jpillora.com/
pop_succes(text)
pop_error(text)
pop_info(text)
pop_warn(text)
pop_succes(text, position)
pop_error(text, position)
pop_info(text, position)
pop_warn(text, position)
pop_succes(text, autoHide)
pop_error(text, duration)
pop_info(text, clickToHide)