MCPcopy Create free account
hub / github.com/TanStack/hotkeys / handleConflict

Function handleConflict

packages/hotkeys/src/manager.utils.ts:202–231  ·  view source on GitHub ↗
(
  conflictingId: string,
  keyDisplay: string,
  conflictBehavior: ConflictBehavior,
  unregister: (id: string) => void,
)

Source from the content-addressed store, hash-verified

200 * @param unregister - Function to unregister by ID
201 */
202export function handleConflict(
203 conflictingId: string,
204 keyDisplay: string,
205 conflictBehavior: ConflictBehavior,
206 unregister: (id: string) => void,
207): void {
208 if (conflictBehavior === 'allow') {
209 return
210 }
211
212 if (conflictBehavior === 'warn') {
213 console.warn(
214 `'${keyDisplay}' is already registered. Multiple handlers will be triggered. ` +
215 `Use conflictBehavior: 'replace' to replace the existing handler, ` +
216 `or conflictBehavior: 'allow' to suppress this warning.`,
217 )
218 return
219 }
220
221 if (conflictBehavior === 'error') {
222 throw new Error(
223 `'${keyDisplay}' is already registered. ` +
224 `Use conflictBehavior: 'replace' to replace the existing handler, ` +
225 `or conflictBehavior: 'allow' to allow multiple registrations.`,
226 )
227 }
228
229 // At this point, conflictBehavior must be 'replace'
230 unregister(conflictingId)
231}

Callers 3

registerMethod · 0.90
registerMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…