/** * Used to create a token that can be sent to foreigh lands a later awaited. * This is different from regular Promise (which this class just wraps) is that Promise does not expose `resolve` function * but this does. It allows you to send somewhere (e.g. in an event) a callback (the `resolve` function) and when this token is awaited * it will wait for the `resolve` to be called * * # Example * * ```typescript * const token = new ResolutionToken() * * // send token elsewhere (then `resolve` is somehow called) * dispatch("someEvent", token.resolve) // svelte dispatch * * // awaits the call of `resolve` * const payloadFromParent = await token * ``` */ export default class ResolutionToken { resolve: ((x: any) => void) | null; reject: ((x: any) => void) | null; private promise; constructor(); then(callback: (x: T) => TRes | Promise): Promise; }