From 9cecee9f54d47a3d4ee7e57b4ecb23ad697758df Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Todor=20Kondi=C4=87?= <todor.kondic@uni.lu>
Date: Fri, 8 May 2020 13:09:29 +0200
Subject: [PATCH] shiny-ui-config: Implement reactive state build-up

From the beginning, the intention was to follow the simple signal
passing paradigm, where a single state object is being passed from
function to function. With a GUI this is complicated by continuously
changing state and in a reactive paradigm of Shiny, additional
complication arises from inability to distinguish between different
inputs for the same destination observer, or reactive function.

But, now that the problem has been solved by adding new reactive state
variables for the project path and the data file control, it was
possible to emulate the streamlined signal processing flow by adding a
few new reactive functions.

Here they are.

* R/shiny-ui-config.R(m_conf,m_input,m): New reactive functions. Each
  builds its part of the m object. Each calls the preceeding one.
---
 R/shiny-ui-config.R | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/R/shiny-ui-config.R b/R/shiny-ui-config.R
index 2e0b513..a379fdb 100644
--- a/R/shiny-ui-config.R
+++ b/R/shiny-ui-config.R
@@ -148,7 +148,34 @@ react_conf_f <- function(input,output,session,rv,rf) {
     })
 
     rf$get_all_sets <- react_e(rv$m$input$tab$setid,unique(rv$m$input$tab$setid$set))
+    rf$m_conf <- react_f({
+        m <- list()
+        m$conf$project <- rv$project_path
+        m$conf$compounds$known <- input$known
+        m$conf$compounds$unknown <- input$unknown
+        m$conf$compounds$sets <- input$sets
+        m$conf$data <- input$datafiles
+        verify_compounds(m$conf)
+        m
+    })
+
+    rf$m_input_cmpds <- react_f({
+        m <- rf$m_conf()
+        load_compound_input(m)
+    })
+
+    rf$m_input <- react_f({
+        m <- rf$m_input_cmpds()
+        mzml <- rf$ctrl2mzml()
+        verify_data_df(mzml=mzml,all_sets=rf$get_all_sets())
+        m$input$tab$mzml <- mzml
+        m
+    })
 
+    
+
+    rf$m <- react_f(rf$m_input())
+    
     rf
 }
 
-- 
GitLab