myuon/quartz

"term is nil" error

Closed this issue · 0 comments

myuon commented
    js_fetch(
        "assets/rhb.json",
        fun (resp_id: i32) {
            let ref = JsRef::new(resp_id);
            let text = jsstring(ref);

            let j or err = Json::from_string(text);
            if err != nil {
                panic("Failed to parse JSON: {}", derive::to_string(err));
            }

            let sheet = Sheet::from_json(j!);

            let rhb = js_image_new();
            js_image_set_src(rhb, "assets/rhb.png");
            js_image_set_onload(
                rhb,
                fun () {
                    js_context_draw_image(context, rhb, 0, 0);
                },
            );
            js_image_set_onerror(
                image,
                fun () {
                    panic("Image failed to load");
                },
            );
        },
    );