Documentation ¶
Overview ¶
Package promises provides helpers for working with promises in k6.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New can be used to create promises that will be dispatched to k6's event loop.
Calling the function will create a goja promise and return its `resolve` and `reject` callbacks, wrapped in such a way that it will block the k6 JavaScript runtime's event loop from exiting before they are called, even if the promise isn't resolved by the time the current script ends executing.
A typical usage would be:
func myAsynchronousFunc(vu modules.VU) *(goja.Promise) { promise, resolve, reject := promises.New(vu) go func() { v, err := someAsyncFunc() if err != nil { reject(err) return } resolve(v) }() return promise }
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.