import { TemporalUnit } from '../temporal-unit'; export interface Until { /** * Persevere, polling the underlying promise function, until either a matching value is provided or the perseverance criteria is breached. * @param expected expected value that the underlying promise function should yield * @return the value that the underlying promise yields */ yieldsValue(expected: T): Promise; /** * Persevere, polling the underlying promise function, until either a value satisfying the predicate is provided or the perseverance criteria is breached. * @param predicate that the underlying promise function should yield a value to satisfy * @return the value that the underlying promise yields */ satisfies(predicate: (value: T) => boolean): Promise; /** * Persevere, polling the underlying promise function, until it stops throwing / rejecting or the perseverance criteria is breached. * @return the value that the underlying promise yields */ noExceptions(): Promise; } export type ErrorHandler = (originalMessage: string, lastResolvedValue?: unknown) => E; export declare abstract class TemporalBinding { protected pollIntervalMillis: number; protected errorHandler: ErrorHandler; /** * Sets the interval to wait between polling the function to check its value / state. * * @param value the value to wait for in the provided unit * @param unit the temporal unit to wait for (e.g. SECONDS) */ withPollInterval(value: number, unit: TemporalUnit): Omit; /** * Sets an error handler that will be called if the promissory function does not satisfy the provided constraints. * * @param handler to call to build an error, will be passed the last resolved value if available */ withErrorHandler(handler: ErrorHandler): Omit; abstract until(promissoryFunction: () => Promise): Until; }