| 489 | |
| 490 | // Supply AbortController without bundling React Native's XHR stack. |
| 491 | class Signal { |
| 492 | aborted = false |
| 493 | reason: unknown = undefined |
| 494 | onabort: ((event: object) => void) | null = null |
| 495 | listeners: Array<(event: object) => void> = [] |
| 496 | addEventListener(type: string, listener: (event: object) => void) { |
| 497 | if (type === "abort") this.listeners.push(listener) |
| 498 | } |
| 499 | removeEventListener(type: string, listener: (event: object) => void) { |
| 500 | const index = this.listeners.indexOf(listener) |
| 501 | if (type === "abort" && index !== -1) this.listeners.splice(index, 1) |
| 502 | } |
| 503 | throwIfAborted() { |
| 504 | if (this.aborted) throw this.reason |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | class Controller { |
| 509 | readonly signal = new Signal() |
nothing calls this directly
no outgoing calls
no test coverage detected