( conflictingId: string, keyDisplay: string, conflictBehavior: ConflictBehavior, unregister: (id: string) => void, )
| 200 | * @param unregister - Function to unregister by ID |
| 201 | */ |
| 202 | export 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 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…