vueProxy: Send commands to a Vue instance in a Shiny app

Description Usage Examples

View source: R/vue.R

Description

Send commands to a Vue instance in a Shiny app

Update data in a Vue instance

Usage

1
2
3
4
vueProxy(outputId, session = shiny::getDefaultReactiveDomain(),
  deferUntilFlush = TRUE)

vueUpdateData(proxy, ...)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
ui <- div(
  tags$label("Enter username"),
  tags$input(type = 'text', "v-model" = "username"),
  tags$p("Vue -> Vue: Hello {{username}}"),
  actionButton("set_name", "Shiny -> Vue"),
  verbatimTextOutput("username")
) %>%
  vue(
    data = list(username = ""),
    # Vue UI -> Shiny UI
    watch = vue_watch("username"),
   elementId = "app"
 )
server <- function(input, output, session){
  # Shiny server -> Vue UI
  observeEvent(input$set_name, {
    vueProxy("app") %>%
      updateProp("username", "Ramnath")
  })
  output$username <- renderPrint({
    paste("Vue -> Shiny:", input$username)
  })
}
shiny::shinyApp(ui = ui, server = server)

ramnathv/vuer documentation built on Nov. 5, 2019, 2:59 a.m.