charliejhadley / gene.alignment.tables

gene.alignment.tables
Other
2 stars 1 forks source link

Roll the observer code into the app #1

Open charliejhadley opened 6 years ago

charliejhadley commented 6 years ago

At present the readme instructs users that they need to add an observer to their Shiny app to watch for column selections of the datatables in the visualisation.

Is it possible to write this into the package so that users could write their server.R as follows:

Any ideas @daattali...

function(input, output, session) {

  alignment.dt.unique.id <- alignment_DT_unique_id()

  output$programmatic_many_DT_UI <- renderUI({

    the_datatables <- my_sequence_data %>%
      generate_dts(table.width = 15,
                   alignment.table.id = alignment.dt.unique.id)

    fluidPage(
      the_datatables
    )

    observer_gene.alignment.tables()

    output$observe_show_inputs <- renderDataTable({
    selected_positions <- selected_col_values[["current"]] %>%
      sort()

    if (is.null(selected_positions)) {

      my_sequence_data[0,] %>%
        datatable()
    } 

    hide("loading-content")

    my_sequence_data %>%
      filter(position %in% selected_positions) %>%
      datatable()
  })

  })
daattali commented 6 years ago

Hi, sorry but I'm away this weekend recording datacamp course and then have to rush to finish a few client projects that I'm very behind on and have to do done before year end. I'm not going to have time to take a look at this

On Dec 22, 2017 6:03 AM, "Martin John Hadley" notifications@github.com wrote:

At present the readme instructs users that they need to add an observer to their Shiny app to watch for column selections of the datatables in the visualisation.

Is it possible to write this into the package so that users could write their server.R as follows:

Any ideas @daattali https://github.com/daattali (should Github support @ing https://github.com/ing you here)...

function(input, output, session) {

alignment.dt.unique.id <- alignment_DT_unique_id()

output$programmatic_many_DT_UI <- renderUI({

the_datatables <- my_sequence_data %>%
  generate_dts(table.width = 15,
               alignment.table.id = alignment.dt.unique.id)

fluidPage(
  the_datatables
)

observer_gene.alignment.tables()

output$observe_show_inputs <- renderDataTable({
selected_positions <- selected_col_values[["current"]] %>%
  sort()

if (is.null(selected_positions)) {

  my_sequence_data[0,] %>%
    datatable()
}

hide("loading-content")

my_sequence_data %>%
  filter(position %in% selected_positions) %>%
  datatable()

})

})

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/martinjhnhadley/gene.alignment.tables/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6IFMPc8npMaffV8zPYKoPg6K8bgth2ks5tC4x6gaJpZM4RK6tA .

charliejhadley commented 6 years ago

@daattali I feel bad tagging you on the 22nd I definitely didn't assume you'd be about over the holidays - I saw on Twitter you were snowed under with preparing for (your first) Christmas celebrations this year! Hope you had a good time, and super excited to hear you're doing a datacamp course - I love those folks.

This package is kinda a cluster **** as it pollutes the output object of a Shiny app horribly. But it was designed for a very specific need, and I think others might dig themselves into similar holes where they would benefit from being able to insert an observer into a Shiny app from a package.

daattali commented 6 years ago

I'll try to take a look closer to the end of the month (the rstudio conference). I have several unfinished and overdue client projects because of my datacamp push in December and have dug myself into a deep hole because of that. All my brain power is being directed to that until I begin to catch up. I just re-read your initial comment and it mentions the README, perhaps include a full current app example code alongside the sample "desired" server code, to make it easier to understand exactly what the goal is