Advanced

Promise observation

How rs-x turns promise resolution into observable state changes using PromiseObserver and PromiseAccessor cache.

Detailed notes

  • PromiseObserverProxyPairFactory has priority 4 and applies to Promise values.
  • PromiseProxyFactory is keyed by Promise instance and reuses one PromiseObserver per promise.
  • No proxy object is created for Promise; observer pair returns proxy: undefined.
  • PromiseObserver attaches target.then(...) and emits once the promise resolves.
  • Resolved values are cached in PromiseAccessor through IResolvedValueCache (WeakMap-backed).
  • PromiseAccessor returns PENDING until resolution cache is available and clears cache on dispose.