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

Method subscribe

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

Source from the content-addressed store, hash-verified

576 }
577
578 subscribe(fn: () => void) {
579 this.subscriptions.add(fn);
580 // Ensure that React reads the collection if we re-subscribe after updates were
581 // already queued. When a hidden Activity is revealed, child nodes re-attach and call
582 // queueUpdate before we can re-subscribe, so the notification is lost.
583 if (this.queuedRender) {
584 fn();
585 }
586 return (): boolean => this.subscriptions.delete(fn);
587 }
588
589 resetAfterSSR(): void {
590 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