Skip to content

Stipple.init and the life cycle of model instances? #99

Answered by essenciary
michaelfliegner asked this question in Q&A
Discussion options

You must be logged in to vote

@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:

  • instantiating a default state on the client side (so that the JS file is unique, can be cached and hosted on CDNs, and does not leak user state)
  • pushing whatever model state you have from the server when the frontend app is ready by listening to the isready event.

This means that you need to add the following to your code:

on(model.isready) do _
  push!(model)
end

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@jochenkrattenmacher
Comment options

@essenciary
Comment options

@AbhimanyuAryan
Comment options

Answer selected by michaelfliegner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants