FM_set_notification {formods} | R Documentation |
Shiny Notification
Description
Generates a notification that should only show once.
Usage
FM_set_notification(state, notify_text, notify_id, type = "info")
Arguments
state |
Module state generating the notification |
notify_text |
Text to go in the notification |
notify_id |
Unique string for this notification |
type |
- Can be either "success", "failure", "info" (default), or "warning" |
Value
Module state with notification text set
Examples
if(interactive()){
library(formods)
library(shiny)
library(shinydashboard)
#https://fontawesome.com/icons?from=io
ui <- dashboardPage(
skin="red",
dashboardHeader(title="Test Notifications"),
dashboardSidebar(
sidebarMenu(
menuItem("Notifications", tabName="example", icon=icon("table"))
)
),
dashboardBody(
tabItems(
tabItem(tabName="example",
fluidRow(
shiny::actionButton("set_notification", "Set Notification"),
shiny::textInput("user_text", label="Notify Text Here", value="Notify me"),
shiny::actionButton("show_notification", "Show Notification")
)
)
)
)
)
# Main app server
server <- function(input, output, session) {
# Need formods state object
sess_res = UD_test_mksession(session, id="UD")
# Captures input and sets the notification
observeEvent(input$set_notification, {
state = FM_fetch_mod_state(session, id="UD")
state = FM_set_notification(state,
notify_text = isolate(input$user_text),
notify_id = "example")
FM_set_mod_state(session, id="UD", state)
})
# Displays the notification
observeEvent(input$show_notification, {
state = FM_fetch_mod_state(session, id="UD")
FM_notify(state, session)
})
}
shinyApp(ui, server)
}
[Package formods version 0.1.6 Index]