zigar.function.Promise(T).resolve(self, value) - chung-leong/zigar GitHub Wiki

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"));
}
import { getText } from './promise-example-1.zig';

const text = await getText();
console.log(text.string);
Hello world

Arguments:

  • self: @This()
  • value: T

Return value:

void


Promise(T)