aboutsummaryrefslogtreecommitdiff
path: root/src/app/root.zig
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-10-05 16:58:46 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2026-10-05 16:58:46 +0200
commit5117cd94bdcc5b76ce4cb428b5ea47a6c5ab6ecf (patch)
treed4437942d58878d0622da5d924a5320e02957bcc /src/app/root.zig
parent7797e27193ea74914cfdb7ef6cb06af8015d4714 (diff)
wasm implement callMethod
Diffstat (limited to 'src/app/root.zig')
-rw-r--r--src/app/root.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/app/root.zig b/src/app/root.zig
index 13d26b8..3d2a82e 100644
--- a/src/app/root.zig
+++ b/src/app/root.zig
@@ -1,13 +1,13 @@
const std = @import("std");
-pub const z = @import("z");
+const z = @import("z");
export fn run() void {
var env: z.Env = .init(std.heap.wasm_allocator);
defer env.deinit();
- var ref = env.getProp(1, "console") catch unreachable;
- var buffer: [255]u8 = undefined;
- var writer: std.Io.Writer = .fixed(&buffer);
- writer.print("hello, wasm: {}", .{ref.await(&env, .object)}) catch unreachable;
- z.env.console.log(writer.buffered());
+ const console = (env.getProp(z.Env.window, "console") catch unreachable).await(&env, .object);
+
+ const call = env.callMethod(console, "log", .{ "hello, wasm!" }) catch unreachable;
+
+ call.await(&env, .undefined);
}