Feature Request: iOS and Android dispose implementations
First off, amazing package. Thanks for the work!
I'm sorry if this is already possible, but I couldn't find any info on it.
The docs mention that every Hybrid Object has a dispose() method. I'm requesting that, as part of the iOS/Android protocol, you be able to implement the dispose() method. This will allow you to clean up native resources during the dispose call.
I guess in this case you'd have to manually declare it in your spec. I'll think about it
I guess in this case you'd have to manually declare it in your spec. I'll think about it
That's fine, too, as long as it doesn't prevent/override the current dispose implementation from happening.
The nice thing about exposing it on Android/iOS is that you can treat it as a finalizer, which will force users of the package to think about cleaning up anything native. Assuming that the garbage collector will always call dispose on the JS side, you can sync up the release of all your resources. For example, Java's implementation of finalization has been removed and is unreliable.
For example, Java's implementation of finalization has been removed and is unreliable.
This is the exactly same in JS. That's why I'm hesitant to implement this. Objects can live for a long time before being deleted by GC. Dispose() is same as the Disposable interface in Java, additional dispose() method with weird behaviour when the user forgets it - that's why it needs IDE help so users get it.
oh - I implemented this already in https://github.com/mrousavy/nitro/pull/770 😅