Tiny helper function for rendering JS on the server side and then bootstrapping on the client
Hey, the readme contains the following snippet of example code:
// server.js
var iso = new Iso()
request.get('/', function (req, res) {
iso.add('<div>Hello, World!</div>', { someSampleData: 'Hello, World!' }, { id: 'hello' })
res.render(iso.render())
})
And I'm wondering whether the Iso instance is supposed to be created outside the request handler like that? Since you're adding state to it, it seems like lifecycle per request would make more sense. Or does it do a flush of internal state when you call .render()
?
I'm trying to get iso to work in order to bootstrap my alt store, but for some reason alt.bootstrap() and alt.flush() doesn't seem to work.
ex:
res.locals.data = { AStore: { something: value } }
var data = res.locals.data
alt.bootstrap(JSON.stringify(data))
var state = alt.flush()
but state ends up being { } and perhaps an example using the new alt api would be nice