Skip to content

How to properly destroy a FileUploader instance? #1288

@mreis1

Description

@mreis1

Hello everyone 👋,

I've been upgrading some old projects and went from ng2-file-upload v1.4.0 to v8.
I noticed that in version 1.4.0, there was a destroy() function available to properly clean up the uploader instance. However, in v8, this function no longer exists, and I couldn't find any reference on how to properly handle the cleanup.

Can someone guide me on the best approach to destroy or clean up the uploader instance in version 8?

Here's what I was doing before:

ngOnDestroy() { 
  this.uploader.destroy(); // ng2-file-upload@1.4.0
}

And here's what I came up with so far for v8:

ngOnDestroy() { 
  this.uploader.clearQueue(); // Clear all remaining files in the queue
  this.uploader = null; // Remove the reference
}

Is this the recommended way? Should I be doing anything else to avoid memory leaks or unexpected behavior?

Thanks for any insights! 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions