lingo.dev icon indicating copy to clipboard operation
lingo.dev copied to clipboard

SDK Modules (/packages/sdk): Add support for the Abort Controller API

Open 7hacker opened this issue 8 months ago • 2 comments

For long-running operations, the SDK could support the standard Abort Controller API to allow consumers to cancel operations:

async localizeText(
 text: string,
 params: Z.infer<typeof localizationParamsSchema>,
 progressCallback?: (progress: number) => void,
 abortSignal?: AbortSignal
): Promise<string> {
 // Check if aborted
 if (abortSignal?.aborted) {
   throw new Error('Operation was aborted');
 }
  // Add abort signal event listener
 const abortListener = () => {
   // Handle abort
 };
  if (abortSignal) {
   abortSignal.addEventListener('abort', abortListener);
 }
  try {
   // Existing logic...
 } finally {
   // Clean up
   if (abortSignal) {
     abortSignal.removeEventListener('abort', abortListener);
   }
 }
}

7hacker avatar Mar 25 '25 03:03 7hacker

seems interesting. I'll take this up.

adisan-dev avatar Mar 25 '25 18:03 adisan-dev

this one is available again, since #587 was abandoned!

maxprilutskiy avatar May 21 '25 19:05 maxprilutskiy

@maxprilutskiy can i work on this ?

VAIBHAVSING avatar Jul 01 '25 10:07 VAIBHAVSING

Sure @VAIBHAVSING , your contributions are always welcome 💯

mathio avatar Jul 01 '25 19:07 mathio

Great job @VAIBHAVSING 🙌 I just merged the PR, releasing in next batch.

mathio avatar Jul 08 '25 09:07 mathio