zigar.function.Promise(T) - chung-leong/zigar GitHub Wiki

Define a promise type that will act as an interface to a JavaScript promise object. Typically, T is going to be an error union. When resolve() is called with a value, then the promise will be fulfilled with that value on the JavaScript side. When the function is given an error instead, then a rejection occurs.

Usage

Arguments:

  • T: type
    Payload of the promise--i.e. what is returned asynchronously.

Struct fields:

  • ptr: ?*anyopaque
  • callback: *const fn (?*anyopaque, T) void

Constants:

  • payload = T

Functions:


Promise