Adam Shaw 5 лет назад
Родитель
Сommit
193297bcd0

+ 1 - 1
packages-premium

@@ -1 +1 @@
-Subproject commit ea4c0aad49411a6779d9941b9fb9284130c5d32e
+Subproject commit 1a43f86ee459d454cb7c00f93c7597d117d1ca4e

+ 0 - 18
packages/__tests__/src/legacy/emitter.js

@@ -17,24 +17,6 @@ describe('emitter', function() {
     expect(handlers.something).toHaveBeenCalled()
   })
 
-  it('calls a handler with context and args', function() {
-    var customContext
-    customContext = {}
-    var o = new EmitterMixin()
-    var handlers = {
-      something: function(arg1, arg2) {
-        expect(this).toBe(customContext)
-        expect(arg1).toBe(2)
-        expect(arg2).toBe(3)
-      }
-    }
-    spyOn(handlers, 'something').and.callThrough()
-
-    o.on('something', handlers.something)
-    o.triggerWith('something', customContext, [ 2, 3 ])
-    expect(handlers.something).toHaveBeenCalled()
-  })
-
   it('unbinds with an exact reference', function() {
     var o = new EmitterMixin()
     var handlers = {

+ 22 - 40
packages/core/src/Calendar.tsx

@@ -1,4 +1,4 @@
-import { EmitterMixin, EmitterInterface } from './common/EmitterMixin'
+import { EmitterMixin } from './common/EmitterMixin'
 import { OptionsInput } from './types/input-types'
 import { DateInput } from './datelib/env'
 import { DateMarker, startOfDay } from './datelib/marker'
@@ -60,18 +60,6 @@ export type ResizeHandler = (force: boolean) => void
 
 export class Calendar {
 
-  // global handler registry
-  static on: EmitterInterface['on']
-  static off: EmitterInterface['off']
-  static trigger: EmitterInterface['trigger']
-
-  on: EmitterInterface['on']
-  one: EmitterInterface['one']
-  off: EmitterInterface['off']
-  trigger: EmitterInterface['trigger']
-  triggerWith: EmitterInterface['triggerWith']
-  hasHandlers: EmitterInterface['hasHandlers']
-
   // derived state
   // TODO: make these all private
   private buildEventUiSingleBase = memoize(buildEventUiSingleBase)
@@ -84,7 +72,7 @@ export class Calendar {
   public defaultTimedEventDuration: Duration
   public slotMinTime: Duration
   public slotMaxTime: Duration
-  private resizeHandlers: ResizeHandler[] = []
+  private resizeHandlers: ResizeHandler[] = [] // TODO: use emitter somehow?
   private toolbarConfig
 
   // interaction
@@ -94,6 +82,7 @@ export class Calendar {
   state: CalendarState = {} as any
   isRendering = false
   isRendered = false
+  emitter = new EmitterMixin(this) // TODO: rename to Emitter
   reducer: CalendarStateReducer
   renderRunner: DelayedRunner
   actionRunner: TaskRunner<Action> // guards against nested action calls
@@ -121,6 +110,7 @@ export class Calendar {
       }
     )
 
+    this.emitter.trigger('_init') // for tests
     this.dispatch({
       type: 'INIT',
       optionOverrides
@@ -180,17 +170,17 @@ export class Calendar {
 
   runAction(action: Action) {
     let oldState = this.state
-    let newState = this.state = this.reducer.reduce(this.state, action, this)
+    let newState = this.state = this.reducer.reduce(this.state, action, this.emitter, this)
 
     if (oldState && oldState.options !== newState.options) {
       this.updateDerivedOptions(newState.options)
     }
 
     if ((!oldState || !oldState.loadingLevel) && newState.loadingLevel) {
-      this.publiclyTrigger('loading', [ true ])
+      this.emitter.trigger('loading', true)
 
     } else if ((oldState && oldState.loadingLevel) && !newState.loadingLevel) {
-      this.publiclyTrigger('loading', [ false ])
+      this.emitter.trigger('loading', false)
     }
   }
 
@@ -261,6 +251,7 @@ export class Calendar {
         onClassNameChange={this.handleClassNames}
         onHeightChange={this.handleHeightChange}
         toolbarConfig={this.toolbarConfig}
+        emitter={this.emitter}
         calendar={this}
       />,
       this.el
@@ -276,7 +267,7 @@ export class Calendar {
       interaction.destroy()
     }
 
-    this.publiclyTrigger('_destroyed')
+    this.emitter.trigger('_destroyed')
   }
 
 
@@ -387,20 +378,13 @@ export class Calendar {
   // -----------------------------------------------------------------------------------------------------------------
 
 
-  hasPublicHandlers(name): boolean {
-    return this.hasHandlers(name) ||
-      this.opt(name) // handler specified in options
+  on(handlerName: string, handler) {
+    this.emitter.on(handlerName, handler)
   }
 
 
-  publiclyTrigger(name, args?) {
-    let optHandler = this.opt(name)
-
-    this.triggerWith(name, this, args)
-
-    if (optHandler) {
-      return optHandler.apply(this, args)
-    }
+  off(handlerName: string, handler) {
+    this.emitter.off(handlerName, handler)
   }
 
 
@@ -620,7 +604,7 @@ export class Calendar {
 
   resizeRunner = new DelayedRunner(() => {
     this.triggerResizeHandlers(true) // should window resizes be considered "forced" ?
-    this.publiclyTrigger('windowResize')
+    this.emitter.trigger('windowResize')
   })
 
 
@@ -739,17 +723,16 @@ export class Calendar {
       jsEvent: pev ? pev.origEvent as MouseEvent : null, // Is this always a mouse event? See #4655
       view: this.view
     }
-    this.publiclyTrigger('select', [ arg ])
+
+    this.emitter.trigger('select', arg)
   }
 
 
   triggerDateUnselect(pev?: PointerDragEvent) {
-    this.publiclyTrigger('unselect', [
-      {
-        jsEvent: pev ? pev.origEvent : null,
-        view: this.view
-      }
-    ])
+    this.emitter.trigger('unselect', {
+      jsEvent: pev ? pev.origEvent : null,
+      view: this.view
+    })
   }
 
 
@@ -762,7 +745,7 @@ export class Calendar {
       view
     }
 
-    this.publiclyTrigger('dateClick', [ arg ])
+    this.emitter.trigger('dateClick', arg)
   }
 
 
@@ -1002,13 +985,12 @@ export class Calendar {
     let time = createDuration(timeInput)
 
     if (time) {
-      this.trigger('scrollRequest', { time })
+      this.emitter.trigger('_scrollRequest', { time })
     }
   }
 
 }
 
-EmitterMixin.mixInto(Calendar)
 
 
 // for memoizers

+ 4 - 2
packages/core/src/CalendarComponent.tsx

@@ -22,6 +22,7 @@ import { ViewComponent } from './structs/view-config'
 import { createFormatter } from './datelib/formatting'
 import { DateEnv } from './datelib/env'
 import { Calendar } from './Calendar'
+import { EmitterMixin } from './common/EmitterMixin'
 
 
 export interface CalendarComponentProps extends CalendarState {
@@ -31,6 +32,7 @@ export interface CalendarComponentProps extends CalendarState {
   onClassNameChange?: (classNameHash) => void // will be fired with [] on cleanup
   onHeightChange?: (height: CssDimValue) => void // will be fired with '' on cleanup
   toolbarConfig
+  emitter: EmitterMixin
   calendar: Calendar
 }
 
@@ -149,13 +151,13 @@ export class CalendarComponent extends Component<CalendarComponentProps, Calenda
     window.addEventListener('beforeprint', this.handleBeforePrint)
     window.addEventListener('afterprint', this.handleAfterPrint)
 
-    this.props.calendar.publiclyTrigger('datesDidUpdate')
+    this.props.emitter.trigger('datesDidUpdate')
   }
 
 
   componentDidUpdate(prevProps: CalendarComponentProps) {
     if (prevProps.dateProfile !== this.props.dateProfile) {
-      this.props.calendar.publiclyTrigger('datesDidUpdate')
+      this.props.emitter.trigger('datesDidUpdate')
     }
   }
 

+ 2 - 2
packages/core/src/ScrollResponder.ts

@@ -17,13 +17,13 @@ export class ScrollResponder {
 
 
   constructor(public calendar: Calendar, public execFunc: ScrollRequestHandler) {
-    calendar.on('scrollRequest', this.handleScrollRequest)
+    calendar.on('_scrollRequest', this.handleScrollRequest)
     this.fireInitialScroll()
   }
 
 
   detach() {
-    this.calendar.off('scrollRequest', this.handleScrollRequest)
+    this.calendar.off('_scrollRequest', this.handleScrollRequest)
   }
 
 

+ 27 - 62
packages/core/src/common/EmitterMixin.ts

@@ -1,91 +1,56 @@
-/*
-USAGE:
-  import { EmitterMixin, EmitterInterface } from './EmitterMixin'
-in class:
-  on: EmitterInterface['on']
-  one: EmitterInterface['one']
-  off: EmitterInterface['off']
-  trigger: EmitterInterface['trigger']
-  triggerWith: EmitterInterface['triggerWith']
-  hasHandlers: EmitterInterface['hasHandlers']
-after class:
-  EmitterMixin.mixInto(TheClass)
-*/
-
 import { applyAll } from '../util/misc'
-import { Mixin } from './Mixin'
-
-export interface EmitterInterface {
-  on(types, handler)
-  one(types, handler)
-  off(types, handler)
-  trigger(type, ...args)
-  triggerWith(type, context, args)
-  hasHandlers(type)
-}
 
-export class EmitterMixin extends Mixin implements EmitterInterface {
 
-  _handlers: any
-  _oneHandlers: any
+export class EmitterMixin {
 
-  on(type, handler) {
-    addToHash(
-      this._handlers || (this._handlers = {}),
-      type,
-      handler
-    )
-    return this // for chaining
+  handlers: any = {}
+  options: any
+
+
+  constructor(private thisContext = null) {
   }
 
-  // todo: add comments
-  one(type, handler) {
-    addToHash(
-      this._oneHandlers || (this._oneHandlers = {}),
-      type,
-      handler
-    )
-    return this // for chaining
+
+  setOptions(options) {
+    this.options = options
+  }
+
+
+  on(type, handler) {
+    addToHash(this.handlers, type, handler)
   }
 
+
   off(type, handler?) {
-    if (this._handlers) {
-      removeFromHash(this._handlers, type, handler)
-    }
-    if (this._oneHandlers) {
-      removeFromHash(this._oneHandlers, type, handler)
-    }
-    return this // for chaining
+    removeFromHash(this.handlers, type, handler)
   }
 
+
   trigger(type, ...args) {
-    this.triggerWith(type, this, args)
-    return this // for chaining
-  }
+    let res = applyAll(this.handlers[type], this.thisContext, args)
 
-  triggerWith(type, context, args) {
-    if (this._handlers) {
-      applyAll(this._handlers[type], context, args)
+    let handlerFromOptions = this.options && this.options[type]
+    if (handlerFromOptions) {
+      res = handlerFromOptions.apply(this.thisContext, args) || res // will keep first result
     }
-    if (this._oneHandlers) {
-      applyAll(this._oneHandlers[type], context, args)
-      delete this._oneHandlers[type] // will never fire again
-    }
-    return this // for chaining
+
+    return res
   }
 
+
   hasHandlers(type) {
-    return (this._handlers && this._handlers[type] && this._handlers[type].length) ||
-      (this._oneHandlers && this._oneHandlers[type] && this._oneHandlers[type].length)
+    return this.handlers[type] && this.handlers[type].length
   }
 
 }
 
+
 function addToHash(hash, type, handler) {
   (hash[type] || (hash[type] = []))
     .push(handler)
 }
 
+
 function removeFromHash(hash, type, handler?) {
   if (handler) {
     if (hash[type]) {

+ 0 - 28
packages/core/src/common/Mixin.ts

@@ -1,28 +0,0 @@
-
-export class Mixin {
-
-  // mix into a CLASS
-  static mixInto(destClass) {
-    this.mixIntoObj(destClass.prototype)
-  }
-
-  // mix into ANY object
-  static mixIntoObj(destObj) {
-    Object.getOwnPropertyNames(this.prototype).forEach((name) => { // copy methods
-      if (!destObj[name]) { // if destination doesn't already define it
-        destObj[name] = this.prototype[name]
-      }
-    })
-  }
-
-  /*
-  will override existing methods
-  TODO: remove! not used anymore
-  */
-  static mixOver(destClass) {
-    Object.getOwnPropertyNames(this.prototype).forEach((name) => { // copy methods
-      destClass.prototype[name] = this.prototype[name]
-    })
-  }
-
-}

+ 10 - 12
packages/core/src/interactions/EventClicking.ts

@@ -35,18 +35,16 @@ export class EventClicking extends Interaction {
       let hasUrlContainer = elementClosest(ev.target as HTMLElement, '.fc-event-forced-url')
       let url = hasUrlContainer ? (hasUrlContainer.querySelector('a[href]') as any).href : ''
 
-      calendar.publiclyTrigger('eventClick', [
-        {
-          el: segEl,
-          event: new EventApi(
-            component.context.calendar,
-            seg.eventRange.def,
-            seg.eventRange.instance
-          ),
-          jsEvent: ev as MouseEvent, // Is this always a mouse event? See #4655
-          view: viewApi
-        }
-      ])
+      calendar.emitter.trigger('eventClick', {
+        el: segEl,
+        event: new EventApi(
+          component.context.calendar,
+          seg.eventRange.def,
+          seg.eventRange.instance
+        ),
+        jsEvent: ev as MouseEvent, // Is this always a mouse event? See #4655
+        view: viewApi
+      })
 
       if (url && !ev.defaultPrevented) {
         window.location.href = url

+ 10 - 12
packages/core/src/interactions/EventHovering.ts

@@ -61,18 +61,16 @@ export class EventHovering extends Interaction {
     let seg = getElSeg(segEl)!
 
     if (!ev || component.isValidSegDownEl(ev.target as HTMLElement)) {
-      calendar.publiclyTrigger(publicEvName, [
-        {
-          el: segEl,
-          event: new EventApi(
-            calendar,
-            seg.eventRange.def,
-            seg.eventRange.instance
-          ),
-          jsEvent: ev as MouseEvent, // Is this always a mouse event? See #4655
-          view: viewApi
-        }
-      ])
+      calendar.emitter.trigger(publicEvName, {
+        el: segEl,
+        event: new EventApi(
+          calendar,
+          seg.eventRange.def,
+          seg.eventRange.instance
+        ),
+        jsEvent: ev as MouseEvent, // Is this always a mouse event? See #4655
+        view: viewApi
+      })
     }
   }
 

+ 1 - 2
packages/core/src/main.ts

@@ -83,9 +83,8 @@ export {
 
 export { unpromisify } from './util/promise'
 
-export { EmitterMixin, EmitterInterface } from './common/EmitterMixin'
+export { EmitterMixin } from './common/EmitterMixin'
 export { DateRange, rangeContainsMarker, intersectRanges, rangesEqual, rangesIntersect, rangeContainsRange } from './datelib/date-range'
-export { Mixin } from './common/Mixin'
 export { PositionCache } from './common/PositionCache'
 export { ScrollController, ElementScrollController, WindowScrollController } from './common/scroll-controller'
 export { Theme } from './theme/Theme'

+ 4 - 2
packages/core/src/reducers/CalendarStateReducer.ts

@@ -20,6 +20,7 @@ import { reduceDateSelection } from './date-selection'
 import { reduceSelectedEvent } from './selected-event'
 import { reduceEventDrag } from './event-drag'
 import { reduceEventResize } from './event-resize'
+import { EmitterMixin } from '../common/EmitterMixin'
 
 
 export class CalendarStateReducer {
@@ -32,7 +33,7 @@ export class CalendarStateReducer {
   private buildDateProfileGenerator = memoize(buildDateProfileGenerators)
 
 
-  reduce(state: CalendarState, action: Action, calendar: Calendar): CalendarState {
+  reduce(state: CalendarState, action: Action, emitter: EmitterMixin, calendar: Calendar): CalendarState {
     let optionOverrides = state.optionOverrides || {}
     let dynamicOptionOverrides = state.dynamicOptionOverrides || {}
 
@@ -61,6 +62,7 @@ export class CalendarStateReducer {
     }
 
     let { options, availableLocaleData } = this.compileOptions(optionOverrides, dynamicOptionOverrides)
+    emitter.setOptions(options)
 
     let pluginHooks = this.buildPluginHooks(options.plugins)
     let viewSpecs = this.buildViewSpecs(pluginHooks.views, optionOverrides, dynamicOptionOverrides)
@@ -85,7 +87,7 @@ export class CalendarStateReducer {
     let dateProfile = reduceDateProfile(state.dateProfile, action, currentDate, dateProfileGenerator)
     currentDate = reduceCurrentDate(currentDate, action, dateProfile)
 
-    let eventSources = reduceEventSources(state.eventSources, action, dateProfile, pluginHooks, options, calendar)
+    let eventSources = reduceEventSources(state.eventSources, action, dateProfile, pluginHooks, options, emitter, calendar)
 
     let nextState = {
       ...state, // preserve previous state from plugin reducers

+ 16 - 10
packages/core/src/reducers/eventSources.ts

@@ -6,8 +6,9 @@ import { DateProfile } from '../DateProfileGenerator'
 import { Action } from './types'
 import { guid } from '../util/misc'
 import { PluginHooks } from '../plugin-system'
+import { EmitterMixin } from '../common/EmitterMixin'
 
-export function reduceEventSources(eventSources: EventSourceHash, action: Action, dateProfile: DateProfile | null, pluginHooks: PluginHooks, rawOptions, calendar: Calendar): EventSourceHash {
+export function reduceEventSources(eventSources: EventSourceHash, action: Action, dateProfile: DateProfile | null, pluginHooks: PluginHooks, rawOptions, emitter: EmitterMixin, calendar: Calendar): EventSourceHash {
   let activeRange = dateProfile ? dateProfile.activeRange : null
 
   switch (action.type) {
@@ -18,11 +19,12 @@ export function reduceEventSources(eventSources: EventSourceHash, action: Action
         activeRange,
         pluginHooks,
         rawOptions,
+        emitter,
         calendar
       )
 
     case 'ADD_EVENT_SOURCES': // already parsed
-      return addSources(eventSources, action.sources, activeRange, pluginHooks, rawOptions, calendar)
+      return addSources(eventSources, action.sources, activeRange, pluginHooks, rawOptions, emitter, calendar)
 
     case 'REMOVE_EVENT_SOURCE':
       return removeSource(eventSources, action.sourceId)
@@ -32,7 +34,7 @@ export function reduceEventSources(eventSources: EventSourceHash, action: Action
     case 'SET_DATE':
     case 'SET_VIEW_TYPE':
       if (dateProfile) {
-        return fetchDirtySources(eventSources, activeRange, pluginHooks, rawOptions, calendar)
+        return fetchDirtySources(eventSources, activeRange, pluginHooks, rawOptions, emitter, calendar)
       } else {
         return eventSources
       }
@@ -45,6 +47,7 @@ export function reduceEventSources(eventSources: EventSourceHash, action: Action
           excludeStaticSources(eventSources, pluginHooks),
         activeRange,
         pluginHooks,
+        emitter,
         calendar
       )
 
@@ -55,6 +58,7 @@ export function reduceEventSources(eventSources: EventSourceHash, action: Action
           excludeStaticSources(eventSources, pluginHooks),
           activeRange,
           pluginHooks,
+          emitter,
           calendar
         )
       } else {
@@ -74,7 +78,7 @@ export function reduceEventSources(eventSources: EventSourceHash, action: Action
 }
 
 
-function addSources(eventSourceHash: EventSourceHash, sources: EventSource[], fetchRange: DateRange | null, pluginHooks: PluginHooks, rawOptions, calendar: Calendar): EventSourceHash {
+function addSources(eventSourceHash: EventSourceHash, sources: EventSource[], fetchRange: DateRange | null, pluginHooks: PluginHooks, rawOptions, emitter: EmitterMixin, calendar: Calendar): EventSourceHash {
   let hash: EventSourceHash = {}
 
   for (let source of sources) {
@@ -82,7 +86,7 @@ function addSources(eventSourceHash: EventSourceHash, sources: EventSource[], fe
   }
 
   if (fetchRange) {
-    hash = fetchDirtySources(hash, fetchRange, pluginHooks, rawOptions, calendar)
+    hash = fetchDirtySources(hash, fetchRange, pluginHooks, rawOptions, emitter, calendar)
   }
 
   return { ...eventSourceHash, ...hash }
@@ -96,7 +100,7 @@ function removeSource(eventSourceHash: EventSourceHash, sourceId: string): Event
 }
 
 
-function fetchDirtySources(sourceHash: EventSourceHash, fetchRange: DateRange, pluginHooks: PluginHooks, rawOptions, calendar: Calendar): EventSourceHash {
+function fetchDirtySources(sourceHash: EventSourceHash, fetchRange: DateRange, pluginHooks: PluginHooks, rawOptions, emitter: EmitterMixin, calendar: Calendar): EventSourceHash {
   return fetchSourcesByIds(
     sourceHash,
     filterHash(sourceHash, function(eventSource) {
@@ -104,6 +108,7 @@ function fetchDirtySources(sourceHash: EventSourceHash, fetchRange: DateRange, p
     }),
     fetchRange,
     pluginHooks,
+    emitter,
     calendar
   )
 }
@@ -128,6 +133,7 @@ function fetchSourcesByIds(
   sourceIdHash: { [sourceId: string]: any },
   fetchRange: DateRange,
   pluginHooks: PluginHooks,
+  emitter: EmitterMixin,
   calendar: Calendar
 ): EventSourceHash {
   let nextSources: EventSourceHash = {}
@@ -136,7 +142,7 @@ function fetchSourcesByIds(
     let source = prevSources[sourceId]
 
     if (sourceIdHash[sourceId]) {
-      nextSources[sourceId] = fetchSource(source, fetchRange, pluginHooks, calendar)
+      nextSources[sourceId] = fetchSource(source, fetchRange, pluginHooks, emitter, calendar)
     } else {
       nextSources[sourceId] = source
     }
@@ -146,7 +152,7 @@ function fetchSourcesByIds(
 }
 
 
-function fetchSource(eventSource: EventSource, fetchRange: DateRange, pluginHooks: PluginHooks, calendar: Calendar) {
+function fetchSource(eventSource: EventSource, fetchRange: DateRange, pluginHooks: PluginHooks, emitter: EmitterMixin, calendar: Calendar) {
   let sourceDef = pluginHooks.eventSourceDefs[eventSource.sourceDefId]
   let fetchId = guid()
 
@@ -164,7 +170,7 @@ function fetchSource(eventSource: EventSource, fetchRange: DateRange, pluginHook
         sourceSuccessRes = eventSource.success(rawEvents, res.xhr)
       }
 
-      let calSuccessRes = calendar.publiclyTrigger('eventSourceSuccess', [ rawEvents, res.xhr ])
+      let calSuccessRes = emitter.trigger('eventSourceSuccess', rawEvents, res.xhr)
       rawEvents = sourceSuccessRes || calSuccessRes || rawEvents
 
       calendar.dispatch({
@@ -182,7 +188,7 @@ function fetchSource(eventSource: EventSource, fetchRange: DateRange, pluginHook
         eventSource.failure(error)
       }
 
-      calendar.publiclyTrigger('eventSourceFailure', [ error ])
+      emitter.trigger('eventSourceFailure', error)
 
       calendar.dispatch({
         type: 'RECEIVE_EVENT_ERROR',

+ 1 - 1
packages/core/src/util/misc.ts

@@ -182,7 +182,7 @@ export function applyAll(functions, thisObj, args) {
     let i
     let ret
     for (i = 0; i < functions.length; i++) {
-      ret = functions[i].apply(thisObj, args) || ret
+      ret = functions[i].apply(thisObj, args) || ret // will keep first results
     }
     return ret
   }

+ 8 - 10
packages/daygrid/src/Table.tsx

@@ -192,16 +192,14 @@ export class Table extends DateComponent<TableProps, TableState> {
     if (typeof clickOption === 'function') {
       // the returned value can be an atomic option
       // TODO: weird how we don't use the `clickOption`
-      clickOption = calendar.publiclyTrigger('moreLinkClick', [
-        {
-          date: dateEnv.toDate(arg.date),
-          allDay: true,
-          allSegs: arg.allSegs.map(segForPublic),
-          hiddenSegs: arg.hiddenSegs.map(segForPublic),
-          jsEvent: arg.ev as MouseEvent, // TODO: better
-          view: viewApi
-        }
-      ])
+      clickOption = calendar.emitter.trigger('moreLinkClick', {
+        date: dateEnv.toDate(arg.date),
+        allDay: true,
+        allSegs: arg.allSegs.map(segForPublic),
+        hiddenSegs: arg.hiddenSegs.map(segForPublic),
+        jsEvent: arg.ev as MouseEvent, // TODO: better
+        view: viewApi
+      })
     }
 
     if (clickOption === 'popover') {

+ 10 - 12
packages/interaction/src/interactions-external/ExternalElementDragging.ts

@@ -135,7 +135,7 @@ export class ExternalElementDragging {
         jsEvent: pev.origEvent as MouseEvent, // Is this always a mouse event? See #4655
         view: finalView
       }
-      receivingCalendar.publiclyTrigger('drop', [ arg ])
+      receivingCalendar.emitter.trigger('drop', arg)
 
       if (dragMeta.create) {
         receivingCalendar.dispatch({
@@ -151,17 +151,15 @@ export class ExternalElementDragging {
         }
 
         // signal that an external event landed
-        receivingCalendar.publiclyTrigger('eventReceive', [
-          {
-            draggedEl: pev.subjectEl as HTMLElement,
-            event: new EventApi(
-              receivingCalendar,
-              droppableEvent.def,
-              droppableEvent.instance
-            ),
-            view: finalView
-          }
-        ])
+        receivingCalendar.emitter.trigger('eventReceive', {
+          draggedEl: pev.subjectEl as HTMLElement,
+          event: new EventApi(
+            receivingCalendar,
+            droppableEvent.def,
+            droppableEvent.instance
+          ),
+          view: finalView
+        })
       }
     }
 

+ 31 - 40
packages/interaction/src/interactions/EventDragging.ts

@@ -117,14 +117,12 @@ export class EventDragging extends Interaction { // TODO: rename to EventSelecti
 
     if (this.isDragging) {
       initialCalendar.unselect(ev) // unselect *date* selection
-      initialCalendar.publiclyTrigger('eventDragStart', [
-        {
-          el: this.subjectEl,
-          event: new EventApi(initialCalendar, eventRange.def, eventRange.instance),
-          jsEvent: ev.origEvent as MouseEvent, // Is this always a mouse event? See #4655
-          view: context.viewApi
-        }
-      ])
+      initialCalendar.emitter.trigger('eventDragStart', {
+        el: this.subjectEl,
+        event: new EventApi(initialCalendar, eventRange.def, eventRange.instance),
+        jsEvent: ev.origEvent as MouseEvent, // Is this always a mouse event? See #4655
+        view: context.viewApi
+      })
     }
   }
 
@@ -231,14 +229,12 @@ export class EventDragging extends Interaction { // TODO: rename to EventSelecti
 
       this.clearDrag() // must happen after revert animation
 
-      initialCalendar.publiclyTrigger('eventDragStop', [
-        {
-          el: this.subjectEl,
-          event: eventApi,
-          jsEvent: ev.origEvent as MouseEvent, // Is this always a mouse event? See #4655
-          view: initialView
-        }
-      ])
+      initialCalendar.emitter.trigger('eventDragStop', {
+        el: this.subjectEl,
+        event: eventApi,
+        jsEvent: ev.origEvent as MouseEvent, // Is this always a mouse event? See #4655
+        view: initialView
+      })
 
       if (validMutation) {
 
@@ -276,18 +272,16 @@ export class EventDragging extends Interaction { // TODO: rename to EventSelecti
             view: initialView
           }
 
-          initialCalendar.publiclyTrigger('eventDrop', [ eventDropArg ])
+          initialCalendar.emitter.trigger('eventDrop', eventDropArg)
 
         // dropped in different calendar
         } else if (receivingCalendar) {
 
-          initialCalendar.publiclyTrigger('eventLeave', [
-            {
-              draggedEl: ev.subjectEl as HTMLElement,
-              event: eventApi,
-              view: initialView
-            }
-          ])
+          initialCalendar.emitter.trigger('eventLeave', {
+            draggedEl: ev.subjectEl as HTMLElement,
+            event: eventApi,
+            view: initialView
+          })
 
           initialCalendar.dispatch({
             type: 'REMOVE_EVENT_INSTANCES',
@@ -306,29 +300,26 @@ export class EventDragging extends Interaction { // TODO: rename to EventSelecti
             })
           }
 
-          let dropArg = {
+          receivingCalendar.emitter.trigger('drop', {
             ...receivingCalendar.buildDatePointApi(finalHit.dateSpan),
             draggedEl: ev.subjectEl as HTMLElement,
             jsEvent: ev.origEvent as MouseEvent, // Is this always a mouse event? See #4655
             view: finalHit.component.context.viewApi
-          }
-          receivingCalendar.publiclyTrigger('drop', [ dropArg ])
-
-          receivingCalendar.publiclyTrigger('eventReceive', [
-            {
-              draggedEl: ev.subjectEl as HTMLElement,
-              event: new EventApi( // the data AFTER the mutation
-                receivingCalendar,
-                mutatedRelevantEvents.defs[eventDef.defId],
-                mutatedRelevantEvents.instances[eventInstance.instanceId]
-              ),
-              view: finalHit.component.context.viewApi
-            }
-          ])
+          })
+
+          receivingCalendar.emitter.trigger('eventReceive', {
+            draggedEl: ev.subjectEl as HTMLElement,
+            event: new EventApi( // the data AFTER the mutation
+              receivingCalendar,
+              mutatedRelevantEvents.defs[eventDef.defId],
+              mutatedRelevantEvents.instances[eventInstance.instanceId]
+            ),
+            view: finalHit.component.context.viewApi
+          })
         }
 
       } else {
-        initialCalendar.publiclyTrigger('_noEventDrop')
+        initialCalendar.emitter.trigger('_noEventDrop')
       }
     }
 

+ 32 - 38
packages/interaction/src/interactions/EventResizing.ts

@@ -80,14 +80,12 @@ export class EventResizing extends Interaction {
     this.draggingSeg = getElSeg(segEl)
 
     calendar.unselect()
-    calendar.publiclyTrigger('eventResizeStart', [
-      {
-        el: segEl,
-        event: new EventApi(calendar, eventRange.def, eventRange.instance),
-        jsEvent: ev.origEvent as MouseEvent, // Is this always a mouse event? See #4655
-        view: viewApi
-      }
-    ])
+    calendar.emitter.trigger('eventResizeStart', {
+      el: segEl,
+      event: new EventApi(calendar, eventRange.def, eventRange.instance),
+      jsEvent: ev.origEvent as MouseEvent, // Is this always a mouse event? See #4655
+      view: viewApi
+    })
   }
 
   handleHitUpdate = (hit: Hit | null, isFinal: boolean, ev: PointerDragEvent) => {
@@ -161,14 +159,12 @@ export class EventResizing extends Interaction {
     let relevantEvents = this.relevantEvents!
     let mutatedRelevantEvents = this.mutatedRelevantEvents!
 
-    calendar.publiclyTrigger('eventResizeStop', [
-      {
-        el: this.draggingSegEl,
-        event: eventApi,
-        jsEvent: ev.origEvent as MouseEvent, // Is this always a mouse event? See #4655
-        view: viewApi
-      }
-    ])
+    calendar.emitter.trigger('eventResizeStop', {
+      el: this.draggingSegEl,
+      event: eventApi,
+      jsEvent: ev.origEvent as MouseEvent, // Is this always a mouse event? See #4655
+      view: viewApi
+    })
 
     if (this.validMutation) {
       calendar.dispatch({
@@ -176,30 +172,28 @@ export class EventResizing extends Interaction {
         eventStore: mutatedRelevantEvents
       })
 
-      calendar.publiclyTrigger('eventResize', [
-        {
-          el: this.draggingSegEl,
-          startDelta: this.validMutation.startDelta || createDuration(0),
-          endDelta: this.validMutation.endDelta || createDuration(0),
-          prevEvent: eventApi,
-          event: new EventApi( // the data AFTER the mutation
-            calendar,
-            mutatedRelevantEvents.defs[eventDef.defId],
-            eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null
-          ),
-          revert: function() {
-            calendar.dispatch({
-              type: 'MERGE_EVENTS',
-              eventStore: relevantEvents
-            })
-          },
-          jsEvent: ev.origEvent,
-          view: viewApi
-        }
-      ])
+      calendar.emitter.trigger('eventResize', {
+        el: this.draggingSegEl,
+        startDelta: this.validMutation.startDelta || createDuration(0),
+        endDelta: this.validMutation.endDelta || createDuration(0),
+        prevEvent: eventApi,
+        event: new EventApi( // the data AFTER the mutation
+          calendar,
+          mutatedRelevantEvents.defs[eventDef.defId],
+          eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null
+        ),
+        revert: function() {
+          calendar.dispatch({
+            type: 'MERGE_EVENTS',
+            eventStore: relevantEvents
+          })
+        },
+        jsEvent: ev.origEvent,
+        view: viewApi
+      })
 
     } else {
-      calendar.publiclyTrigger('_noEventResize')
+      calendar.emitter.trigger('_noEventResize')
     }
 
     // reset all internal state