export interface PromiseCallbacks { resolve: (value: T) => void; reject: (reason?: any) => void; metadata?: K; } export class PromiseWithCallbacks { promise: Promise; resolve!: (value: T) => void; reject!: (reason?: any) => void; constructor(cb: (resolve: (value: T) => void, reject: (reason?: any) => void) => any) { this.promise = new Promise((resolve, reject) => { this.resolve = resolve; this.reject = reject; cb(resolve, reject); }); } }