You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since we have a bunch of new features in GenieFramework 3 I want to discuss a possible new template with the following features
precompilabe
distributable as package
startable by using MyGenie
revisable handler functions without page reload, making AutoReload unnecessary
faster startup times (for the template below 17 s => 12s)
Here it is (the first two functions would go into Stipple, of course)
# app.jlcd(@__DIR__)
tryusing MyGenie
catch _
using Pkg
Pkg.develop(url =".", name ="MyGenie")
using MyGenie
end# src/MyGenie.jlmodule MyGenie
using Stipple, Stipple.ReactiveTools
using StippleUI
using Genie
import Stipple.Pages.Page, Genie.Router.Route
function Genie.route(p::Stipple.Pages.Page)
p in Stipple.Pages._pages ||push!(Stipple.Pages._pages, p)
route(p.route)
endmacroprecompile_route(url, view, App =nothing)
quoteroute($url) dopage(@init($App), $view) |> html
view_fn =$view isa Function ? html! : html
# without `layout = nothing` the function is not compilableif$App ===nothingview_fn($view; layout =nothing, context =@__MODULE__, model =@init())
elseview_fn($view; layout =nothing, context =@__MODULE__, model =@init($App))
endendend|> esc
end@app MyApp begin@in x =1@in y = x +1@onchange x on_x()
@onchange x, y on_x_y()
end@handler MyApp functionon_x()
@info"x changed"end@handler MyApp functionon_x_y()
@info"x or y changed to $x, $y"endui() = [
row("Hello World {{ x }}, {{ y }}")
slider(1:10, :x)
slider(11:20, :y)
]
ui2() =htmldiv([
row("Hello World {{ x }}, {{ y }}")
card([
cardsection(slider(1:10, :x))
cardsection(slider(11:20, :y))
])
])
p::Page=@page("/", ui, model = MyApp)
r::Route=route("/page2") do
view =htmldiv(ui())
html!(ui, context =@__MODULE__, layout =DEFAULT_LAYOUT(), model =@init(MyApp))
endfunction__init__()
route(p)
route(r)
up(open_browser =true)
end@stipple_precompilebegin@precompile_route("/", ui, MyApp)
@precompile_route("/page2", ui2, MyApp)
precompile_get("/")
precompile_get("/page2")
endend# module MyGenie
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Since we have a bunch of new features in GenieFramework 3 I want to discuss a possible new template with the following features
using MyGenie
Here it is (the first two functions would go into Stipple, of course)
Beta Was this translation helpful? Give feedback.
All reactions