zigar.function.Promise(T).resolve(self, value) ᴾᴴᴾ - chung-leong/zigar GitHub Wiki
JavaScript | PHP
Resolve the promise by invoking callback with the value given as an argument alongside the opaque
pointer stored in the struct.
Usage:
const std = @import("std");
const zigar = @import("zigar");
const Promise = zigar.function.Promise(error{OutOfMemory}![]const u8);
pub fn getText(a: std.mem.Allocator, promise: Promise) void {
promise.resolve(a.dupe(u8, "Hello world"));
}
<?php
$m = zigar_use(__DIR__ . '/promise-example-1.zig');
$text = $m->getText();
echo "$text\n";
Hello world
Arguments:
self:@This()value:T
Return value:
void