Genie modularize @app logic

vh94
Tue, 05 Aug 2025 12:40:20 +0000
Web Stack

Is there a way to programmatically initialize @in and @out vars in GenieFramework.jl ?

I would like to call a type of constructor from a module sever logic using namespaces , :tree, :ghost, to not have to initialize everything explicitly inside the main App function :

@app begin

  @in  ghostname = "Genie"
  @in  ghostmessage = "nothing to report"
  @out ghostage = 9878

  @in  treename = "Oak"
  @in  treemessage = "nothing to report"
  @out treeage = 234
end

Eqivalent to an UI constructor that creates identical input cards with name-spaced variables:

function ui_elem(ns::String, name::String="name", age::String = "age", message::String = "message")

    name_ns,age_ns,message_ns = Symbol.(Symbol(ns),[name,age,message])

      row([
      cell(class="st-module",[

        h4("Module of :$ns"),
        textfield("Enter your name $ns", name_ns,filled = String(name_ns)),
        p("Your age is {{age_ns}} ; $age_ns"), # how to display outvars?
        textfield("Enter your concern", message_ns, filled =String(message_ns)),
      ])
    ])
end

called inside main UI in App.jl:

function ui()
  [
    h1("modularized app"),
    [ui_elem(i) for i in ["ghost","tree"] ]...,
    p("A Ghost of the name {{ghostname}} and age {{ghostage}} years thinks: {{ghostmessage}}"),
    p("A tree of the name {{treename}} and age {{treeage}} thinks {{treemessage}}"),

  ]
end

How would an compaignon constructor for @in and @out reactive vars look like?

Can the code be boundled in a generic module /lib/Being.jl?

In Rshiny the design pattern of shiny-modules allows to boundle “server” and “ui” logic in a namespaced module, I tried to achieve a similar thing in GenieFramework.jl and modules in /lib/ but its unclear to me how/where to initialize/scope/pass variables?
./lib/Being.jl (click for more details) ./App.jl (click for more details)
1 post - 1 participant