mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 18:13:40 -05:00
537673cdf6
IDE scope store and emitter with fixed PDF URLs GitOrigin-RevId: 9d33bad8a006bb55714878332f78932538dd8921
17 lines
489 B
TypeScript
17 lines
489 B
TypeScript
import { useCallback } from 'react'
|
|
import { useIdeContext } from '../context/ide-context'
|
|
import { ScopeEventName } from '../../../../types/ide/scope-event-emitter'
|
|
|
|
export default function useScopeEventEmitter(
|
|
eventName: ScopeEventName,
|
|
broadcast = true
|
|
) {
|
|
const { scopeEventEmitter } = useIdeContext()
|
|
|
|
return useCallback(
|
|
(...detail: unknown[]) => {
|
|
scopeEventEmitter.emit(eventName, broadcast, ...detail)
|
|
},
|
|
[scopeEventEmitter, eventName, broadcast]
|
|
)
|
|
}
|