Closed ryanw-mobile closed 1 year ago
Thank you!
You're right, we should probably just wrap the statement
mInstance.disconnect();
in a try
block and ignore the IllegalStateException
like this:
try {
mInstance.disconnect();
}
catch (IllegalStateException ignored) {}
That seems to match the goal of the MeteorSingleton
class (which is simple management of the instance) and that of the destroyInstance
method (which is to ensure that the instance is both disconnected and destroyed). Do you agree?
Yes, I agree with that.
If it is already disconnected when calling
MeteorSingleton.destroyInstance()
, it will throwjava.lang.IllegalStateException: You must have called the 'connect' method before you can disconnect again
.That means every time if I need to destroy the instance when disconnected, I have to reestablish the connection, just for destroyinstance() to disconnect it, which sounds a bit strange to me.
Could the IllegalStateException be handled internally within
destroyinstance()
, or is it possible to have a way to simply setminstance = null
? Thanks!