Add removeUploadHandlers function to signalrService for improved memory management by detaching event handlers, preventing memory leaks and multiple triggers.

This commit is contained in:
burakovec
2026-03-26 12:38:29 +03:00
parent 3c4db6d312
commit 2ecda61ad4

View File

@ -56,3 +56,13 @@ export const onCompleted = (callback: (data: any) => void) => {
export const onError = (callback: (data: any) => void) => {
if (connection) connection.on('ReceiveError', callback)
}
/** Upload event handler'larını kaldır (memory leak ve çoklu tetikleme önleme) */
export const removeUploadHandlers = () => {
if (connection) {
connection.off('ReceiveProgress')
connection.off('ReceiveInsertProgress')
connection.off('ReceiveCompleted')
connection.off('ReceiveError')
}
}