Submit
Path:
~
/
/
usr
/
share
/
grafana
/
public
/
app
/
core
/
hooks
/
File Content:
useBusEvent.ts
import { useEffect, useState } from 'react'; import { BusEvent, BusEventType, EventBus } from '@grafana/data'; /** A bit more efficient than using useObservable(eventBus.getStream(MyEventType)) as that will create a new Observable and subscription every render */ export function useBusEvent<T extends BusEvent>(eventBus: EventBus, eventType: BusEventType<T>): T | undefined { const [event, setEvent] = useState<T | undefined>(); useEffect(() => { const sub = eventBus.subscribe(eventType, setEvent); return () => sub.unsubscribe(); }, [eventBus, eventType]); return event; }
Submit
FILE
FOLDER
INFO
Name
Size
Permission
Action
useBusEvent.ts
599 bytes
0644
useCleanup.ts
602 bytes
0644
useMediaQueryChange.ts
519 bytes
0644
useNavModel.ts
291 bytes
0644
useQueryParams.ts
592 bytes
0644
N4ST4R_ID | Naxtarrr