Skip to content

Commit

Permalink
docs: document new experimentalSuspend function
Browse files Browse the repository at this point in the history
  • Loading branch information
cprecioso committed Dec 9, 2023
1 parent 28b4c32 commit ae8676f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/suspend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@ import { suspendOnPromise } from "./lib/suspend";

const cache = new WeakMap<Promise<any>, StoredCacheValue<any>>();

export const suspend = <T>(promise: Promise<T>): T =>
/**
* @hidden
*
* **Experimental** This is a function that can suspend on any promise,
* without creating a cache first (it uses a WeakMap). Users beware,
* it needs testing on whether it creates reference cycles, or whether
* it works at all. This is hidden from the documentation for a reason.
*
* This is undocumented and thus breaking changes might happen in
* between minor releases.
*/
export const experimentalSuspend = <T>(promise: Promise<T>): T =>
suspendOnPromise(
() => promise,
cache.get(promise),
Expand Down

0 comments on commit ae8676f

Please sign in to comment.