Files
speckle-server/packages/frontend-2/lib/common/utils/requests.ts
T
Kristaps Fabians Geikins 83d8035dc2 chore: upgrade to eslint 9 (#2348)
* root + server

* frontend

* frontend-2

* dui3

* dui3

* tailwind theme

* ui-components

* preview service

* viewer

* viewer-sandbox

* fileimport-service

* webhook service

* objectloader

* shared

* ui-components-nuxt

* WIP full config

* WIP full linter

* eslint projectwide util

* minor fix

* removing redundant ci

* clean up test errors

* fixed prettier formatting

* CI improvements

* TSC lint fix

* 'buildBatch' needs to be async since some batch types (like Text) require it. Removed a disabled liniting rule from ObjLoader

* removed unnecessary void

---------

Co-authored-by: AlexandruPopovici <alexandrupopoviciioan@gmail.com>
2024-06-12 14:38:02 +03:00

32 lines
754 B
TypeScript

import type { Nullable } from '@speckle/shared'
import { get, isObjectLike } from 'lodash-es'
export const abortControllerManager = () => {
let abortController: Nullable<AbortController> = null
const pop = () => {
// Abort old
if (abortController) abortController.abort()
abortController = null
// Create new
abortController = new AbortController()
return abortController
}
return {
pop,
popOnlyInCSR: () => {
if (import.meta.server) return null
return pop()
},
popOnlyInSSR: () => {
if (import.meta.client) return null
return pop()
}
}
}
export const isAbortError = (error: unknown): error is DOMException =>
isObjectLike(error) && get(error, 'name') === 'AbortError'