Skip to content

Commit

Permalink
feat(types): EVow
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg authored and 0xpatrickdev committed Jul 1, 2024
1 parent 8c27c67 commit 3d5a3f3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
6 changes: 3 additions & 3 deletions packages/vow/src/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { makeAsVow } from './vow-utils.js';

/**
* @import {Zone} from '@agoric/base-zone';
* @import {IsRetryableReason, AsPromiseFunction} from './types.js';
* @import {IsRetryableReason, AsPromiseFunction, Vow, EVow} from './types.js';
*/

/**
Expand All @@ -33,9 +33,9 @@ export const prepareVowTools = (zone, powers = {}) => {
/**
* Vow-tolerant implementation of Promise.all.
*
* @param {unknown[]} vows
* @param {EVow<unknown>[]} maybeVows
*/
const allVows = vows => watchUtils.all(vows);
const allVows = maybeVows => watchUtils.all(maybeVows);

/** @type {AsPromiseFunction} */
const asPromise = (specimenP, ...watcherArgs) =>
Expand Down
6 changes: 6 additions & 0 deletions packages/vow/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ export {};
* @typedef {T | PromiseLike<T>} ERef
*/

/**
* Eventually a value T or Vow for it.
* @template T
* @typedef {ERef<T | Vow<T>>} EVow
*/

/**
* Follow the chain of vow shortening to the end, returning the final value.
* This is used within E, so we must narrow the type to its remote form.
Expand Down
13 changes: 6 additions & 7 deletions packages/vow/src/watch-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import { PromiseWatcherI } from '@agoric/base-zone';
const { Fail, bare, details: X } = assert;

/**
* @import {MapStore} from '@agoric/store/src/types.js'
* @import { Zone } from '@agoric/base-zone'
* @import { Watch } from './watch.js'
* @import { When } from './when.js'
* @import {VowKit, AsPromiseFunction} from './types.js'
* @import {IsRetryableReason} from './types.js'
* @import {MapStore} from '@agoric/store/src/types.js';
* @import {Zone} from '@agoric/base-zone';
* @import {Watch} from './watch.js';
* @import {When} from './when.js';
* @import {VowKit, AsPromiseFunction, IsRetryableReason, Vow, EVow} from './types.js';
*/

const VowShape = M.tagged(
Expand Down Expand Up @@ -81,7 +80,7 @@ export const prepareWatchUtils = (
{
utils: {
/**
* @param {unknown[]} vows
* @param {EVow<unknown>[]} vows
*/
all(vows) {
const { nextId: id, idToVowState } = this.state;
Expand Down
4 changes: 2 additions & 2 deletions packages/vow/src/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { apply } = Reflect;

/**
* @import { PromiseWatcher, Zone } from '@agoric/base-zone';
* @import { ERef, IsRetryableReason, Vow, VowKit, VowResolver, Watcher } from './types.js';
* @import { ERef, EVow, IsRetryableReason, Vow, VowKit, VowResolver, Watcher } from './types.js';
*/

/**
Expand Down Expand Up @@ -170,7 +170,7 @@ export const prepareWatch = (
* @template [TResult1=T]
* @template [TResult2=never]
* @template {any[]} [C=any[]] watcher args
* @param {ERef<T | Vow<T>>} specimenP
* @param {EVow<T>} specimenP
* @param {Watcher<T, TResult1, TResult2, C>} [watcher]
* @param {C} watcherArgs
*/
Expand Down

0 comments on commit 3d5a3f3

Please sign in to comment.