MessageCollection: what does dispose() do?

Hi, I’m trying to understand what exactly does dispose() do for GroupChannelCollection and MessageCollection?

I can’t seemed to find the difference by console.logging the collection instance before and after calling dispose().

Asking this because I’m trying to completely remove the MessageCollection instance after using it. Initially thought calling messageCollection.dispose() would work, but it seems like we could still call messageCollection.loadNext() after that. Is that an expected behaviour?

What I wanted to do is to clean it up from the SDK, as if it never existed. Wondering if that is only achievable by disconnecting from the SDK?

Would appreciate some help here, thank you.

Hello, would appreciate if anyone could help me understand this

Hello @hewong,

My sincerest apologies for just a delayed response. I took a look through the code and it looks like dispose() does a couple of things. Such as:

  • Closes background sync
  • Closes changelog sync
  • Unsubscribes group channel events.

If you’re looking to clear it out completely, it may be better off calling clearCachedData or clearCachedMessages on the main Sendbird instance.