Stipple.init and the life cycle of model instances? #99
Answered
by
essenciary
michaelfliegner
asked this question in
Q&A
-
I would want to display a model on different pages. But changing the page - by using a form for instance - resets the model fields to initial values. So ... if the model instance "dies" when the page changes, then I would want
PLS help! my code: model=handlers(Stipple.init(Model; transport = Genie.WebThreads))
ctx=@__MODULE__
route("/") do
println(ctx)
html(ui(model),context=ctx )
end
route("/sub", method = POST) do
age = params(:age, "99")
name = params(:name, "Schnipperdey")
println("PARAMS " * name * " " * string(age))
redirect("/")
end |
Beta Was this translation helpful? Give feedback.
Answered by
essenciary
Mar 29, 2022
Replies: 1 comment 3 replies
-
@michaelfliegner It looks like you instantiate the model as a global, so it should survive on the server side between pages. The design pattern to generate the state on the client consists of 2 steps:
This means that you need to add the following to your code: on(model.isready) do _
push!(model)
end |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
michaelfliegner
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@michaelfliegner It looks like you instantiate the model as a global, so it should survive on the server side between pages.
The design pattern to generate the state on the client consists of 2 steps:
isready
event.This means that you need to add the following to your code: