( registry: AtomRegistry.AtomRegistry, atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>, suspendOnWaiting: boolean )
| 298 | WeakMap<Atom.Atom<any>, Promise<void>> |
| 299 | >(), |
| 300 | default: new WeakMap< |
| 301 | AtomRegistry.AtomRegistry, |
| 302 | WeakMap<Atom.Atom<any>, Promise<void>> |
| 303 | >() |
| 304 | } |
| 305 | |
| 306 | function atomToPromise<A, E>( |
| 307 | registry: AtomRegistry.AtomRegistry, |
| 308 | atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>, |
| 309 | suspendOnWaiting: boolean |
| 310 | ) { |
| 311 | const registries = suspendOnWaiting ? atomPromiseMap.suspendOnWaiting : atomPromiseMap.default |
| 312 | let map = registries.get(registry) |
| 313 | if (map === undefined) { |
| 314 | map = new WeakMap() |
| 315 | registries.set(registry, map) |
| 316 | } |
| 317 | let promise = map.get(atom) |
| 318 | if (promise !== undefined) { |
| 319 | return promise |
| 320 | } |
| 321 | promise = new Promise<void>((resolve) => { |
| 322 | const dispose = registry.subscribe(atom, (result) => { |
| 323 | if (result._tag === "Initial" || (suspendOnWaiting && result.waiting)) { |
| 324 | return |
| 325 | } |
no test coverage detected
searching dependent graphs…