1 | import { useCollector } from './useCollector.js';
|
2 | import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.js';
|
3 | export function useMonitorOutput(monitor, collect, onCollect) {
|
4 | const [collected, updateCollected] = useCollector(monitor, collect, onCollect);
|
5 | useIsomorphicLayoutEffect(function subscribeToMonitorStateChange() {
|
6 | const handlerId = monitor.getHandlerId();
|
7 | if (handlerId == null) {
|
8 | return;
|
9 | }
|
10 | return monitor.subscribeToStateChange(updateCollected, {
|
11 | handlerIds: [
|
12 | handlerId
|
13 | ]
|
14 | });
|
15 | }, [
|
16 | monitor,
|
17 | updateCollected
|
18 | ]);
|
19 | return collected;
|
20 | }
|
21 |
|
22 |
|
\ | No newline at end of file |