Skip to content

Instantly share code, notes, and snippets.

@timelyportfolio
Last active July 21, 2021 14:36
Show Gist options
  • Select an option

  • Save timelyportfolio/e2cf088a4cfccfbb1bdbf19ffd07f679 to your computer and use it in GitHub Desktop.

Select an option

Save timelyportfolio/e2cf088a4cfccfbb1bdbf19ffd07f679 to your computer and use it in GitHub Desktop.

Revisions

  1. timelyportfolio revised this gist Apr 18, 2017. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions Readme.md
    Original file line number Diff line number Diff line change
    @@ -42,3 +42,6 @@ server <- function(input,output){

    shinyApp(ui,server)
    ```

    ### Screenshot
    ![vue-shiny](https://cloud.githubusercontent.com/assets/837910/25143277/716ede6e-242f-11e7-9113-bd293072b09e.gif)
  2. timelyportfolio revised this gist Apr 18, 2017. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion Readme.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ I have assembled [`vueR`](https://github.com/timelyportfolio/vueR) package, like
    devtools::install_github("timelyportfolio/vueR")`
    ```

    ### Code
    ### Example

    ```r

    @@ -23,6 +23,7 @@ ui <- tagList(
    textOutput("textrepeat"),
    tags$script(
    "
    // wait for shiny:connected so that Shiny.shinyapp.$inputValues will exist
    $(document).on('shiny:connected', function(a,b,c){
    var vb = new Vue({
    el: '#app',
    @@ -35,6 +36,7 @@ $(document).on('shiny:connected', function(a,b,c){
    )

    server <- function(input,output){
    # repeat text typed in textinput with Shiny
    output$textrepeat <- renderText({paste0("from Shiny: ", input$textinput)})
    }

  3. timelyportfolio revised this gist Apr 18, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Readme.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ### Shiny = good, Vue = good | Shiny + Vue = good?
    ### Shiny == good & Vue == good | Shiny + Vue == good?

    Shiny `Shiny.shinyapp.$inputValues` acts like a store of state. I thought it would be fun to let [`vuejs`](https://vuejs.org) react to changes in `Shiny` input values. This example is intentionally very simple to hopefully self-explain.

  4. timelyportfolio created this gist Apr 18, 2017.
    42 changes: 42 additions & 0 deletions Readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    ### Shiny = good, Vue = good | Shiny + Vue = good?

    Shiny `Shiny.shinyapp.$inputValues` acts like a store of state. I thought it would be fun to let [`vuejs`](https://vuejs.org) react to changes in `Shiny` input values. This example is intentionally very simple to hopefully self-explain.

    ### vueR

    I have assembled [`vueR`](https://github.com/timelyportfolio/vueR) package, like `d3r` and `reactR`, to offer helpers for `vuejs`. For this example please install `vueR`, or just add `tags$script(src = "https://unpkg.com/vue@2.2.6")` to the `tagList()`.

    ```
    devtools::install_github("timelyportfolio/vueR")`
    ```

    ### Code

    ```r

    library(shiny)
    library(htmltools)

    ui <- tagList(
    textInput("textinput", label="Enter Something"),
    div(id="app","from Vue: {{textinput}}"),
    textOutput("textrepeat"),
    tags$script(
    "
    $(document).on('shiny:connected', function(a,b,c){
    var vb = new Vue({
    el: '#app',
    data: Shiny.shinyapp.$inputValues
    });
    });
    "
    ),
    vueR:::html_dependency_vue()
    )

    server <- function(input,output){
    output$textrepeat <- renderText({paste0("from Shiny: ", input$textinput)})
    }

    shinyApp(ui,server)
    ```
    25 changes: 25 additions & 0 deletions code.R
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    library(shiny)
    library(htmltools)

    ui <- tagList(
    textInput("textinput", label="Enter Something"),
    div(id="app","from Vue: {{textinput}}"),
    textOutput("textrepeat"),
    tags$script(
    "
    $(document).on('shiny:connected', function(a,b,c){
    var vb = new Vue({
    el: '#app',
    data: Shiny.shinyapp.$inputValues
    });
    });
    "
    ),
    vueR:::html_dependency_vue()
    )

    server <- function(input,output){
    output$textrepeat <- renderText({paste0("from Shiny: ", input$textinput)})
    }

    shinyApp(ui,server)