@@ -88,6 +88,8 @@ import sketch/lustre as sketch_lustre
8888pub fn main() {
8989 // Initialise the cache. Two strategies can be used. Ephemeral caches are designed as throw-away caches.
9090 let assert Ok(stylesheet) = sketch.stylesheet(strategy: sketch.Ephemeral)
91+ // Setup the cache. This should be done once before using the render.
92+ let assert Ok(stylesheet) = sketch.setup(stylesheet)
9193 // Generate the partial view function, compatible with Lustre's runtime.
9294 lustre.simple(init, update, view(_, stylesheet))
9395 // And voilà!
@@ -96,7 +98,7 @@ pub fn main() {
9698
9799fn view(model, stylesheet) {
98100 // Add the sketch CSS generation "view middleware".
99- use <- sketch_lustre.render(stylesheet, [sketch_lustre.node()])
101+ use <- sketch_lustre.render(stylesheet:, in: [sketch_lustre.node()])
100102 // Run your actual view function.
101103 my_view(model)
102104}
@@ -149,24 +151,6 @@ And you're done! Enjoy your Lustre app, Sketch-enhanced!
149151
150152### Final notes
151153
152- #### On Sketch Lustre Element
153-
154- A Sketch ` Element(msg) ` is extremely similar to a Lustre ` Element(msg) ` ,
155- excepted it carries styles information on top. Going from a
156- ` sketch/lustre/element.Element(msg) ` to a ` lustre/element.Element(msg) ` is
157- straightforward, by using ` sketch/lustre/element.unstyled ` . The opposite (going
158- from a Lustre element to a Sketch Lustre element) is also possible by using
159- ` sketch/lustre/element.styled ` !
160-
161- #### Sketch Lustre Experimental
162-
163- Because sometimes you may want to avoid the ` Element(msg) ` overhead, you can try
164- the experimental Sketch Lustre runtime, ` sketch_lustre_experimental ` . That
165- runtime works in the same way, excepts it does not implements its own ` Element `
166- type on top of Lustre's ` Element ` . Most of the time, you should not see any
167- differences. Keep in mind that it can bug though, as it's still experimental. If
168- you try to use it, please, report any bugs you can find.
169-
170154#### Usage with Shadow DOM
171155
172156In browser, Sketch can work with a Shadow DOM, in order to hide the compiled
0 commit comments