sketch/redraw

Types

Cache required to initialise Sketch Redraw. Use it in conjuction with provider.

pub opaque type Cache

Values

pub fn create_cache() -> Cache

Creates the Sketch Context and initialises the Sketch cache. Use it in conjuction with provider to setup Sketch Redraw, otherwise nothing will work.

import redraw
import redraw/dom/client
import sketch/redraw as sketch_redraw

pub fn main() {
  let app = app()
  let cache = sketch_redraw.create_cache()
  let root = client.create_root("root")
  client.render(root, {
    redraw.strict_mode([
      sketch_redraw.provider(cache, [
        app(),
      ]),
    ])
  })
}
pub fn provider(
  setup: Cache,
  children: List(redraw.Component),
) -> redraw.Component

Create the Sketch provider used to manage the StyleSheet.
This makes sure identical styles will never be computed twice.
Use it at root of your render function.

import redraw
import redraw/dom/client
import sketch/redraw as sketch_redraw

pub fn main() {
  let app = app()
  let cache = sketch_redraw.create_cache()
  let root = client.create_root("root")
  client.render(root, {
    redraw.strict_mode([
      sketch_redraw.provider(cache, [
        app(),
      ]),
    ])
  })
}
Search Document