通知を表示するオブザーバーを追加する
オブザーバーは、ブラウザにプロットやテーブル、テキストを表示するなどの副作用に使われます。既定では、基盤となる依存関係のいずれかが変化すると、オブザーバーは処理を実行します。
この演習では、observe() と showNotification() を使って、ブラウザに通知を表示するオブザーバーを作成します。オブザーバーで動作をトリガーするので、render***() 関数を使ったり、結果を output に代入したりする必要はありません。
この演習はコースの一部です
Rで作るShiny Webアプリケーション
演習の手順
- サーバー内にオブザーバーを追加して、通知
'You have entered the name xxxx'を表示します。ここでxxxxは入力から取得した名前です。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
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)