lingo.dev
lingo.dev copied to clipboard
SDK Modules (/packages/sdk): Add support for the Abort Controller API
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);
}
}
}
seems interesting. I'll take this up.
this one is available again, since #587 was abandoned!
@maxprilutskiy can i work on this ?
Sure @VAIBHAVSING , your contributions are always welcome 💯
Great job @VAIBHAVSING 🙌 I just merged the PR, releasing in next batch.