overleaf/services/web/frontend/js/features/ide-react/scope-event-emitter/angular-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

22 lines
674 B
TypeScript

import {
ScopeEventEmitter,
ScopeEventName,
} from '../../../../../types/ide/scope-event-emitter'
import { Scope } from '../../../../../types/angular/scope'
export class AngularScopeEventEmitter implements ScopeEventEmitter {
// eslint-disable-next-line no-useless-constructor
constructor(readonly $scope: Scope) {}
emit(eventName: ScopeEventName, broadcast: boolean, ...detail: unknown[]) {
if (broadcast) {
this.$scope.$broadcast(eventName, ...detail)
} else {
this.$scope.$emit(eventName, ...detail)
}
}
on(eventName: ScopeEventName, listener: (...args: unknown[]) => void) {
return this.$scope.$on(eventName, listener)
}
}