title: Nested Reactive Expressions in Shiny
body: <p>I am trying to create a simple app with these features :</p>
  
  <p>User will select "Custom" or "Default".</p>
  
  <p>If "Default" is selected, a default text will be shown. But if "Custom" is selected, user will be able to "Submit" a text and that submitted text will be shown.</p>
  
  <p>I have written some code to do this, but unable to handle the two reactive expressions simultaneously in the "Custom" case.</p>
  
  <p>Here is the code :</p>
  
  <pre><code>library( shiny )
  
  ui = navbarPage(
  
  title = 'Text',
  
  tabPanel(
  
  'Custom App',
  
  fluidRow(
  
  
    radioButtons( 'radio', 'Select Action', choices = list( 'Default' = 'Default', 'Custom' = 'Custom' ),
  
                  selected = 'Default', inline = T ),
  
    column( 6, textInput( 'text_given', label = 'Enter Text', value = '' ) ),
  
    actionButton( 'submit_button', 'Submit' ),
  
    textOutput( text )
  
    )
  
  )
  
  )
  
  server = function( input, output, session ){
  
  main = reactive({
  
  selected_action = input$radio
  
    if( selected_action == 'Default' ){
  
      text_to_show = 'Default Text'
  
    } else{
  
      dataInput = eventReactive( input$submit_button,{
  
        text_to_show = input$text_given
  
      })
  
   }
  
   return( list( 'text_output' = text_to_show ) )
  
  })
  
  output$text = renderText( main()$text_output )
  
  }
  
  shinyApp( ui = ui, server = server )
  </code></pre>