MCPcopy Create free account
hub / github.com/adobe/react-spectrum / subscribe

Method subscribe

packages/react-aria/src/collections/Document.ts:599–608  ·  view source on GitHub ↗
(fn: () => void)

Source from the content-addressed store, hash-verified

597 }
598
599 subscribe(fn: () => void) {
600 this.subscriptions.add(fn);
601 // Ensure that React reads the collection if we re-subscribe after updates were
602 // already queued. When a hidden Activity is revealed, child nodes re-attach and call
603 // queueUpdate before we can re-subscribe, so the notification is lost.
604 if (this.queuedRender) {
605 fn();
606 }
607 return (): boolean => this.subscriptions.delete(fn);
608 }
609
610 resetAfterSSR(): void {
611 if (this.isSSR) {

Callers 2

useCollectionDocumentFunction · 0.45
ToastContainerFunction · 0.45

Calls 3

fnFunction · 0.85
deleteMethod · 0.80
addMethod · 0.65

Tested by

no test coverage detected