type Retsync2promiseOptions = { /** * Whenever retsyncFn hits a promise2retsync. it is run again and checked, if it behaves fine and repeatable and hits that same promise again (saves it properly) */ checkSaved?: boolean; }; /** * Internal / used in frameworks. */ export declare class Retsync2promiseCall { } /** * Global state. Internal / shared with frameworks. */ export declare const _global: { resolvedPromiseValues: WeakMap, unknown>; retsync2promiseCall?: Retsync2promiseCall; globalObj: {}; resourcePromises: import("./Util").DefaultMap>>; }; /** * Let's you run retsync code and wait, till it is finished. * Errors by promises won't be catched. They will fall down, so you can catch them. Error state is not cached, so it will always be tried fresh on every retsync2promise run. * @param repeatableFn * @param options */ export declare function retsync2promise(repeatableFn: () => T, options?: Retsync2promiseOptions): Promise; /** * Makes a promise usable in retsync code. * @param savedPromise You must save/fix the promise somewhere, so you reuse it the next time you encounter it. */ export declare function promise2retsync(savedPromise: Promise): T; /** * Makes async code usable in retsync code. *

* Because retsync code is repeatable. This call must be associated a certain **identifiable resource**, so we know if that resource is already at loading progress. * Therefore, you have the idObj and idKey parameters. Example: * asyncResource2retsync( async() => {...load the avatar...}, myUser, "getAvatar"); * So the User#getAvatar is, what uniquely identifies the loaderFn here. *

*

* Error handling: Failed promises (loaderFn fails) are forgotten, so next time the retsync code invokes asyncResource2retsync, it is tried fresh again *

* @param loaderFn * @param idObj object to associate this call to. undefined means globally and the idKey primitive value is the only key. * @param idKey Additional primitive key under idObj. * @see cleanResource */ export declare function asyncResource2retsync(loaderFn: () => Promise, idObj: object | undefined, idKey?: (string | number)): T; /** * Cleans the promise and therefore the result behind the given obj+key like used in {@link asyncResource2retsync}. * Call this i.e. on the event that the resource has change and you want to "invalidate the cached value", so it will be fetched fresh next time. * @param idObj * @param idKey */ export declare function cleanResource(idObj: object | undefined, idKey?: (string | number)): void; export declare class RetsyncWaitsForPromiseException extends Error { promise: Promise; /** * Overrides {@link Retsync2promiseOptions#checkSaved} */ checkSaved?: boolean; constructor(promise: Promise); } export declare function checkThatCallerHandlesRetsync(): void; export {}; /** * Makes a an async function usable in retsync code. */ //# sourceMappingURL=retsync.d.ts.map