Genie Discord forum
![Author Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Hi friends here, the more I use genie, the more I love it!!! Now I put many of my code into web. Thank you! Genie guys. And since I have many small tools in genie, I would like to ask if there any easy way to put them all together into a toolkit?
let me make it more clear, I build many apps for myself's usage, and they are smililar in the code structure, but have different reactive variable and output page, for example: this is app1
# app1
@app begin
@in xxx = 1
@in yyy = 2
@out result = 0
@onchange xxx,yyy begin
result = xxx + yyy
end
end
@page("/app1_page", "app1.html")
and this is app2
# app2
@in V = Int64[]
@out result = Int64[]
@onchange V begin
result = V.^2
end
@page("/app2_page", "app2.html")
what I want to do is to merge them together, I can do it by just pool all code into one file, such as app.jl, it works but it is messy, so I try to split the code into different files and include them in when needed, so when I visit "localhost/app1", it will go to app1, and load app1's reactive variable and html file, below is want I try, but it does not work:
app1.jl:
@in xxx = 1
@in yyy = 2
@out result = 0
@onchange xxx,yyy begin
result = xxx + yyy
end
toolkit.jl:
global appList = ["app1","app2"]
global current_app = "app1"
@app begin
include("$(current_app).jl")
end
for app in appList
route("/$(app)") do
global currentapp = app
Genie.Renderer.redirect("/$(app)_page", 302)
end
@page("/$(app)_page", "$(app).html" )
end
any suggetion on this? Thank you very much !!!!
![Author Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
Hello, in Multiple app modules paragraph : https://learn.genieframework.com/docs/guides/adding-reactive-pages it is divided with module and sub-module, perhaps it will help you. regards
![Author Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Thanks @bienpierre so much!!! it helps a lots.
![Author Avatar](https://cdn.discordapp.com/avatars/960642755799941150/8454099b3f43462890d75bc9c4cd572d.png?size=512)
You can also create named apps in a single module:
@app App1 begin
@in xxx = 1
@in yyy = 2
@out result = 0
@onchange xxx,yyy begin
result = xxx + yyy
end
end
@app App1 begin
@in V = Int64[]
@out result = Int64[]
@onchange V begin
result = V.^2
end
end
@page("/app1_page", "app1.html", model = App1)
@page("/app2_page", "app2.html", model = App2)
![Author Avatar](https://cdn.discordapp.com/avatars/960642755799941150/8454099b3f43462890d75bc9c4cd572d.png?size=512)
Or you can merge such apps into one:
@app MyGeneralApp begin
@mixin App1
@mixin App2
end
Currently, only the fields are merged, but the handlers are not! There is a PR in place that would even allow to merge the mixins: https://github.com/GenieFramework/Stipple.jl/pull/245
@mixins [App1, App2]
![Author Avatar](https://cdn.discordapp.com/avatars/960642755799941150/8454099b3f43462890d75bc9c4cd572d.png?size=512)
But that's work in progress. In the long run the handlers should be merged automatically.
![Author Avatar](https://cdn.discordapp.com/avatars/960642755799941150/8454099b3f43462890d75bc9c4cd572d.png?size=512)
@essenciary shall we allow alternative keyword app
instead of model
?
![Author Avatar](https://cdn.discordapp.com/avatars/738049963250155580/13375362e7047976b44a466ef441a20f.png?size=512)
won't that be confusing given that we also have @app
?
![Author Avatar](https://cdn.discordapp.com/avatars/960642755799941150/8454099b3f43462890d75bc9c4cd572d.png?size=512)
It would read
@page("/app1_page", "app1.html", app = App1)
@page("/app2_page", "app2.html", app = App2)
![Author Avatar](https://cdn.discordapp.com/avatars/960642755799941150/8454099b3f43462890d75bc9c4cd572d.png?size=512)
That looks quite natural as @app
creates an App, which then can be passed by kw
![Author Avatar](https://cdn.discordapp.com/avatars/738049963250155580/13375362e7047976b44a466ef441a20f.png?size=512)
@hhaensel In general I don't like having multiple names for one thing... it complicates user understanding, it complicates dev understanding, it adds code and makes code slower
![Author Avatar](https://cdn.discordapp.com/avatars/738049963250155580/13375362e7047976b44a466ef441a20f.png?size=512)
I've seen the code for this in your branch - quite a few more computations for no gain really
![Author Avatar](https://cdn.discordapp.com/avatars/738049963250155580/13375362e7047976b44a466ef441a20f.png?size=512)
in principle I'm ok with replacing all references to the idea of model with that of app - but adding a chunk of code just to support a different keyword doesn't justify the cons IMO
![Author Avatar](https://cdn.discordapp.com/avatars/738049963250155580/13375362e7047976b44a466ef441a20f.png?size=512)
it's a matter of principle: 5 years of this and the code becomes a slow codebase of redundant options
![Author Avatar](https://cdn.discordapp.com/avatars/960642755799941150/8454099b3f43462890d75bc9c4cd572d.png?size=512)
Let's discuss the wording model vs. app in a call. My idea would be, app is the type, model is the instance
![Author Avatar](https://cdn.discordapp.com/avatars/738049963250155580/13375362e7047976b44a466ef441a20f.png?size=512)
ok - let's discuss in detail (my current thinking is that with the new API the model has disappeared... the user only sees @app)
![Author Avatar](https://cdn.discordapp.com/avatars/960642755799941150/8454099b3f43462890d75bc9c4cd572d.png?size=512)
I still don't like the invisible model type too much. My personal favourite would be to have named models as the basis and, if really needed, grab the model from a Dict{Module, ReactiveModel}
![Author Avatar](https://cdn.discordapp.com/avatars/960642755799941150/8454099b3f43462890d75bc9c4cd572d.png?size=512)
But that's also something g for a call
![Author Avatar](https://cdn.discordapp.com/avatars/738049963250155580/13375362e7047976b44a466ef441a20f.png?size=512)
ok - yes, we should discuss a cleanup - we can probably remove a lot of legacy code and some layers
![Author Avatar](https://cdn.discordapp.com/avatars/738049963250155580/13375362e7047976b44a466ef441a20f.png?size=512)
my main concern is the lack of scope in @app blocks
![Author Avatar](https://cdn.discordapp.com/avatars/960642755799941150/8454099b3f43462890d75bc9c4cd572d.png?size=512)
Agree 💯