Explorar el Código

rename to emitter

Adam Shaw hace 5 años
padre
commit
4813e5bd80

+ 1 - 1
packages-premium

@@ -1 +1 @@
-Subproject commit 1a43f86ee459d454cb7c00f93c7597d117d1ca4e
+Subproject commit dd387a0606c4833cbea14ea7d394989367c3d118

+ 4 - 4
packages/__tests__/src/legacy/emitter.js

@@ -1,9 +1,9 @@
-import { EmitterMixin } from '@fullcalendar/core'
+import { Emitter } from '@fullcalendar/core'
 
 describe('emitter', function() {
 
   it('calls a handler', function() {
-    var o = new EmitterMixin()
+    var o = new Emitter()
     var handlers = {
       something: function(arg1, arg2) {
         expect(arg1).toBe(7)
@@ -18,7 +18,7 @@ describe('emitter', function() {
   })
 
   it('unbinds with an exact reference', function() {
-    var o = new EmitterMixin()
+    var o = new Emitter()
     var handlers = {
       something: function() {}
     }
@@ -34,7 +34,7 @@ describe('emitter', function() {
   })
 
   it('unbinds all when no reference', function() {
-    var o = new EmitterMixin()
+    var o = new Emitter()
     var handlers = {
       something1: function() {},
       something2: function() {}

+ 2 - 2
packages/core/src/Calendar.tsx

@@ -1,4 +1,4 @@
-import { EmitterMixin } from './common/EmitterMixin'
+import { Emitter } from './common/Emitter'
 import { OptionsInput } from './types/input-types'
 import { DateInput } from './datelib/env'
 import { DateMarker, startOfDay } from './datelib/marker'
@@ -82,7 +82,7 @@ export class Calendar {
   state: CalendarState = {} as any
   isRendering = false
   isRendered = false
-  emitter = new EmitterMixin(this) // TODO: rename to Emitter
+  emitter = new Emitter(this)
   reducer: CalendarStateReducer
   renderRunner: DelayedRunner
   actionRunner: TaskRunner<Action> // guards against nested action calls

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

@@ -22,7 +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'
+import { Emitter } from './common/Emitter'
 
 
 export interface CalendarComponentProps extends CalendarState {
@@ -32,7 +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
+  emitter: Emitter
   calendar: Calendar
 }
 

+ 1 - 1
packages/core/src/common/EmitterMixin.ts → packages/core/src/common/Emitter.ts

@@ -1,7 +1,7 @@
 import { applyAll } from '../util/misc'
 
 
-export class EmitterMixin {
+export class Emitter {
 
   handlers: any = {}
   options: any

+ 3 - 3
packages/core/src/interactions/ElementDragging.ts

@@ -1,4 +1,4 @@
-import { EmitterMixin } from '../common/EmitterMixin'
+import { Emitter } from '../common/Emitter'
 
 /*
 An abstraction for a dragging interaction originating on an event.
@@ -15,10 +15,10 @@ subclasses must emit:
 */
 export abstract class ElementDragging { // TODO: rename to *Interface?
 
-  emitter: EmitterMixin
+  emitter: Emitter
 
   constructor(el: HTMLElement) {
-    this.emitter = new EmitterMixin()
+    this.emitter = new Emitter()
   }
 
   destroy() {

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

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

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

@@ -20,7 +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'
+import { Emitter } from '../common/Emitter'
 
 
 export class CalendarStateReducer {
@@ -33,7 +33,7 @@ export class CalendarStateReducer {
   private buildDateProfileGenerator = memoize(buildDateProfileGenerators)
 
 
-  reduce(state: CalendarState, action: Action, emitter: EmitterMixin, calendar: Calendar): CalendarState {
+  reduce(state: CalendarState, action: Action, emitter: Emitter, calendar: Calendar): CalendarState {
     let optionOverrides = state.optionOverrides || {}
     let dynamicOptionOverrides = state.dynamicOptionOverrides || {}
 

+ 6 - 6
packages/core/src/reducers/eventSources.ts

@@ -6,9 +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'
+import { Emitter } from '../common/Emitter'
 
-export function reduceEventSources(eventSources: EventSourceHash, action: Action, dateProfile: DateProfile | null, pluginHooks: PluginHooks, rawOptions, emitter: EmitterMixin, calendar: Calendar): EventSourceHash {
+export function reduceEventSources(eventSources: EventSourceHash, action: Action, dateProfile: DateProfile | null, pluginHooks: PluginHooks, rawOptions, emitter: Emitter, calendar: Calendar): EventSourceHash {
   let activeRange = dateProfile ? dateProfile.activeRange : null
 
   switch (action.type) {
@@ -78,7 +78,7 @@ export function reduceEventSources(eventSources: EventSourceHash, action: Action
 }
 
 
-function addSources(eventSourceHash: EventSourceHash, sources: EventSource[], fetchRange: DateRange | null, pluginHooks: PluginHooks, rawOptions, emitter: EmitterMixin, calendar: Calendar): EventSourceHash {
+function addSources(eventSourceHash: EventSourceHash, sources: EventSource[], fetchRange: DateRange | null, pluginHooks: PluginHooks, rawOptions, emitter: Emitter, calendar: Calendar): EventSourceHash {
   let hash: EventSourceHash = {}
 
   for (let source of sources) {
@@ -100,7 +100,7 @@ function removeSource(eventSourceHash: EventSourceHash, sourceId: string): Event
 }
 
 
-function fetchDirtySources(sourceHash: EventSourceHash, fetchRange: DateRange, pluginHooks: PluginHooks, rawOptions, emitter: EmitterMixin, calendar: Calendar): EventSourceHash {
+function fetchDirtySources(sourceHash: EventSourceHash, fetchRange: DateRange, pluginHooks: PluginHooks, rawOptions, emitter: Emitter, calendar: Calendar): EventSourceHash {
   return fetchSourcesByIds(
     sourceHash,
     filterHash(sourceHash, function(eventSource) {
@@ -133,7 +133,7 @@ function fetchSourcesByIds(
   sourceIdHash: { [sourceId: string]: any },
   fetchRange: DateRange,
   pluginHooks: PluginHooks,
-  emitter: EmitterMixin,
+  emitter: Emitter,
   calendar: Calendar
 ): EventSourceHash {
   let nextSources: EventSourceHash = {}
@@ -152,7 +152,7 @@ function fetchSourcesByIds(
 }
 
 
-function fetchSource(eventSource: EventSource, fetchRange: DateRange, pluginHooks: PluginHooks, emitter: EmitterMixin, calendar: Calendar) {
+function fetchSource(eventSource: EventSource, fetchRange: DateRange, pluginHooks: PluginHooks, emitter: Emitter, calendar: Calendar) {
   let sourceDef = pluginHooks.eventSourceDefs[eventSource.sourceDefId]
   let fetchId = guid()
 

+ 3 - 3
packages/interaction/src/dnd/PointerDragging.ts

@@ -1,4 +1,4 @@
-import { config, elementClosest, EmitterMixin, PointerDragEvent } from '@fullcalendar/core'
+import { config, elementClosest, Emitter, PointerDragEvent } from '@fullcalendar/core'
 
 config.touchMouseIgnoreWait = 500
 
@@ -24,7 +24,7 @@ export class PointerDragging {
   containerEl: EventTarget
   subjectEl: HTMLElement | null = null
   downEl: HTMLElement | null = null
-  emitter: EmitterMixin
+  emitter: Emitter
 
   // options that can be directly assigned by caller
   selector: string = '' // will cause subjectEl in all emitted events to be this element
@@ -45,7 +45,7 @@ export class PointerDragging {
 
   constructor(containerEl: EventTarget) {
     this.containerEl = containerEl
-    this.emitter = new EmitterMixin()
+    this.emitter = new Emitter()
     containerEl.addEventListener('mousedown', this.handleMouseDown as EventListener)
     containerEl.addEventListener('touchstart', this.handleTouchStart as EventListener, { passive: true })
     listenerCreated()

+ 3 - 3
packages/interaction/src/interactions/HitDragging.ts

@@ -1,5 +1,5 @@
 import {
-  EmitterMixin, PointerDragEvent,
+  Emitter, PointerDragEvent,
   isDateSpansEqual,
   computeRect,
   constrainPoint, intersectRects, getRectCenter, diffPoints, Point,
@@ -28,7 +28,7 @@ export class HitDragging {
 
   droppableStore: InteractionSettingsStore
   dragging: ElementDragging
-  emitter: EmitterMixin
+  emitter: Emitter
 
   // options that can be set by caller
   useSubjectCenter: boolean = false
@@ -51,7 +51,7 @@ export class HitDragging {
     dragging.emitter.on('dragend', this.handleDragEnd)
 
     this.dragging = dragging
-    this.emitter = new EmitterMixin()
+    this.emitter = new Emitter()
   }
 
   handlePointerDown = (ev: PointerDragEvent) => {