prepareVowTools
The prepareVowTools function is designed to create a set of tools that facilitate working with promises and vows within the Agoric framework. It provides utilities to handle vow-tolerant implementations of promise-related functionalities, along with various other utilities to manage asynchronous operations more effectively.
const { when, watch, makeVowKit, allVows, asVow, asPromise } = prepareVowTools(
zone.subZone('vows'), powers
);Inputs Parameters
zone(Type:Zone): The zone which is used to prepare the toolspowers(Type:object, Optional): An optional parameter that can include additional functionalities. It can contain the following property:isRetryableReason(Type:IsRetryableReason, Optional): A function that determines if the vow is retry-able. Defaults to a function that returnsfalse.
Return Value
The function returns an object with the following utilities:
when(specimenP, onFulfilled, onRejected): A function that triggers aonFulfilledoronRejectedbased on the result of the input vowwatch(specimenP, watcher, ...watcherArgs): A function that facilitates subscribing a watcher to a vow in a way that survives upgrades of both the creator and subscribing client vatsmakeVowKit(): A function that helps in getting thevowandresolverutilities.allVows(vows): A function similar toPromise.allthat ensures all vows in the input array are handled correctly.asVow(fn): A utility function that coerces a given input function into a vow.asPromise(specimenP, ...watcherArgs): A function to convert a vow into a promise, with optional watcher arguments.
By returning these tools, prepareVowTools provides a comprehensive set of utilities to manage vows effectively in an Agoric environment.