Skip to content

Commit

Permalink
fix Controller$clone() method.
Browse files Browse the repository at this point in the history
It was not behaving crrectly anymore when controller was initialized
  • Loading branch information
FrancoisGuillem committed Aug 4, 2017
1 parent 9e1b7c5 commit ab71d7c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion R/controller.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ MWController <- setRefClass(
},

init = function() {
catIfDebug("Controller initialization")
if (!initialized) {
initialized <<- TRUE
inputList$init()
Expand Down Expand Up @@ -213,9 +214,13 @@ MWController <- setRefClass(
),
autoUpdate
)
res$renderFunc <- renderFunc
res$charts <- charts
res$outputFunc <- outputFunc
res$renderFunc <- renderFunc
res$useCombineWidgets <- useCombineWidgets
res$initialized <- initialized
res$inputList$initialized <- initialized

res
},

Expand Down
6 changes: 3 additions & 3 deletions R/input_list_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ InputList <- setRefClass(
inputId <- input$getID()
deps <- getDeps(input)
for (d in deps$params) {
inputs[[d]]$revDeps <<- c(.self$inputs[[d]]$revDeps, inputId)
inputs[[d]]$revDeps <<- union(.self$inputs[[d]]$revDeps, inputId)
}
for (d in deps$display) {
inputs[[d]]$displayRevDeps <<- c(.self$inputs[[d]]$displayRevDeps, inputId)
inputs[[d]]$displayRevDeps <<- union(.self$inputs[[d]]$displayRevDeps, inputId)
}
}
},
Expand All @@ -57,6 +57,7 @@ InputList <- setRefClass(
updateHTMLVisibility = function(name, chartId = 1, inputId = NULL) {
if (!is.null(session)) {
input <- getInput(name, chartId, inputId)
catIfDebug("Update visibility of", input$getID())
shiny::updateCheckboxInput(
session,
paste0(input$getID(), "_visible"),
Expand Down Expand Up @@ -107,7 +108,6 @@ InputList <- setRefClass(

updateRevDeps = function(input) {
if (!initialized) return()

for (inputId in input$revDeps) {
revDepInput <- getInput(inputId = inputId)
if(!identical(revDepInput$value, revDepInput$updateValue())) {
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-controller.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ describe("MWController", {
controller1$setValue("a", "test")
expect_equal(controller1$getValue("a"), "test")
expect_equal(controller2$getValue("a"), "a")
expect_true(controller2$initialized)
expect_true(controller2$inputList$initialized)
})

it("accesses parameters of a given input", {
Expand Down

0 comments on commit ab71d7c

Please sign in to comment.