overleaf/services/web/frontend/js/shared/hooks/use-scope-event-emitter.ts
Tim Down 537673cdf6 Merge pull request #15415 from overleaf/td-scope-store-and-emitter-fixed
IDE scope store and emitter with fixed PDF URLs

GitOrigin-RevId: 9d33bad8a006bb55714878332f78932538dd8921
2023-10-25 08:05:07 +00:00

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]
)
}