LoslegenKostenlos loslegen

Add an observer to display notifications

Recall that an observer is used for side effects, like displaying a plot, table, or text in the browser. By default an observer triggers an action, whenever one of its underlying dependencies change.

In this exercise, you will use an observer to display a notification in the browser, using observe() and showNotification(). As we are triggering an action using an observer, we do NOT need to use a render***() function or assign the results to an output.

Diese Übung ist Teil des Kurses

Building Web Applications with Shiny in R

Kurs anzeigen

Anleitung zur Übung

  • Add an observer in the server to display a notification 'You have entered the name xxxx', where xxxx is the name from the input.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

ui <- fluidPage(
  textInput('name', 'Enter your name')
)

server <- function(input, output, session) {
  # CODE BELOW: Add an observer to display a notification
  # 'You have entered the name xxxx' where xxxx is the name

  
  
  
  
}

shinyApp(ui = ui, server = server)
Code bearbeiten und ausführen