You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
handler1 pointer 11ac100
handler2 pointer 11ac100
handler1 A
handler2 A
handler2 B
Note that even though we removed handler2, it still got an the B event.
What's happening is that EventBus uses reflect.ValueOf().Pointer() for Unsubscribe. However, the pointer to a function isn't enough to distinguish one closure from another. You can see the problem in the above output where it shows that the pointer values for handler1 and handler2 are the same.
The text was updated successfully, but these errors were encountered:
I've just hit this bug. As I show in this playground, you can just use plain == to compare reflect.Values containing lambdas and it seems to work correcly.
Unsubscribe is broken with closures. This code shows the problem:
Here's the output:
Note that even though we removed
handler2
, it still got an theB
event.What's happening is that EventBus uses
reflect.ValueOf().Pointer()
forUnsubscribe
. However, the pointer to a function isn't enough to distinguish one closure from another. You can see the problem in the above output where it shows that the pointer values for handler1 and handler2 are the same.The text was updated successfully, but these errors were encountered: