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

Method subscribe

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

Source from the content-addressed store, hash-verified

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