Add removeUploadHandlers function to signalrService for improved memory management by detaching event handlers, preventing memory leaks and multiple triggers.
This commit is contained in:
@ -56,3 +56,13 @@ export const onCompleted = (callback: (data: any) => void) => {
|
|||||||
export const onError = (callback: (data: any) => void) => {
|
export const onError = (callback: (data: any) => void) => {
|
||||||
if (connection) connection.on('ReceiveError', callback)
|
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')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user