I am working within a shiny app and I want to be able to access information on the current tab a user is on in a session.
I have a observe event that listens for a particular button to be clicked. In simple, I would like to store/print the current tab the user is on when they click this button. After they click this button the tab is changed to 'help' with the updateTabItems which takes the session, inputId and selected values as parameters.
# Observe event when someone clicks a button
observeEvent(input$help, {
# if they are logged in
if(USER$Logged == TRUE) {
# current_tab <- ???
shiny_session <<- session
updateTabItems(session, "sidebar", selected = "help")
}
})
Since the session holds some value I tried to explore it.
> class(shiny_session)
[1] "ShinySession" "R6"
> names(shiny_session)
[1] ".__enclos_env__" "session"
[3] "groups" "user"
[5] "singletons" "request"
[7] "closed" "downloads"
[9] "files" "token"
[11] "clientData" "output"
[13] "input" "progressStack"
[15] "clone" "decrementBusyCount"
[17] "incrementBusyCount" "outputOptions"
[19] "manageInputs" "manageHiddenOutputs"
[21] "registerDataObj" "registerDownload"
[23] "fileUrl" "saveFileUrl"
[25] "handleRequest" "@uploadEnd"
[27] "@uploadInit" "@uploadieFinish"
[29] "reload" "reactlog"
[31] "onFlushed" "onFlush"
[33] "sendInputMessage" "sendCustomMessage"
[35] "dispatch" "sendProgress"
[37] "showProgress" "flushOutput"
[39] "defineOutput" "setShowcase"
[41] "isEnded" "isClosed"
[43] "wsClosed" "close"
[45] "unhandledError" "onInputReceived"
[47] "onEnded" "onSessionEnded"
[49] "ns" "makeScope"
[51] "initialize"
I tried to explore these elements of the shiny session and they are mostly structured as functions and could not find anything on the current tab.
UpdateTabItems seems to take values and sends them to sendInputMessage.
> updateTabItems
function (session, inputId, selected = NULL)
{
message <- dropNulls(list(value = selected))
session$sendInputMessage(inputId, message)
}
This appears to be some sort of stack of commands that gets executed in the shiny app so I stopped exploring it.
> shiny_session$sendInputMessage
function (inputId, message)
{
data <- list(id = inputId, message = message)
private$inputMessageQueue[[length(private$inputMessageQueue) +
1]] <- data
}
Any suggestions on how I could access the current tab information in a variable at a given point in time?
Thanks.