MCPcopy
hub / github.com/editablejs/editable / off

Method off

packages/editor/src/plugin/emitter.ts:94–124  ·  view source on GitHub ↗
(type: string | number, listener: Listener)

Source from the content-addressed store, hash-verified

92 }
93
94 off(type: string | number, listener: Listener): this {
95 const list = this.events[type]
96 if (list === undefined) return this
97
98 if (list === listener) {
99 if (--this.eventsCount === 0) this.events = {}
100 else {
101 delete this.events[type]
102 }
103 } else if (typeof list !== 'function') {
104 let position = -1
105
106 for (let i = list.length - 1; i >= 0; i--) {
107 if (list[i] === listener) {
108 position = i
109 break
110 }
111 }
112
113 if (position < 0) return this
114
115 if (position === 0) list.shift()
116 else {
117 list.splice(position, 1)
118 }
119
120 if (list.length === 1) this.events[type] = list[0]
121 }
122
123 return this
124 }
125
126 once(type: string | number, listener: Listener, prepend = false): this {
127 const wrapper = (...args: any[]) => {

Callers 15

wrapperMethod · 0.95
withEditableFunction · 0.80
event.tsFile · 0.80
EditableProviderFunction · 0.80
ContentEditableFunction · 0.80
useEventFunction · 0.80
constructorMethod · 0.80
destroyMethod · 0.80
_subDocsHandlerMethod · 0.80
SlashToolbarSearchFunction · 0.80
useToolbarEffectFunction · 0.80
SideToolbarFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected