Provide an easy way to add/remove ably channel state listeners #964
Labels
bug
Something isn't working. It's clear that this does need to be fixed.
code-quality
Affects the developer experience when working in our codebase.
In #963, we had to introduce a local boolean check in two places to prevent duplicate resumptions of continuations related to ably channel state changes (the duplicates call exceptions to be thrown).
This was necessary because in Ably.kt (DefaultAbly) we wrap the standard Ably state change listeners in our own classes, meaning we cannot get the object that's registered with ably to be able to call
channel.off()
. We also have to send the "initial" state before the listener is attached to the channel, which presents a race condition. Changing this would require some careful thinking, so in the interest of time we added the work-around to solve the issue in the short term.We should look to go back and readdress this so that we use the standard
channel.off()
way of unsubscribing listeners (and listeners can unsubscribe themselves) in the future.The text was updated successfully, but these errors were encountered: