dvandenham / EventBus

Simple and fast EventBus for Java
0 stars 0 forks source link

Duplicate registration of modern event subscribers #1

Open dvandenham opened 4 days ago

dvandenham commented 4 days ago

https://github.com/dvandenham/EventBus/blob/05d5682a4221388ff1c851e326394f89bdc8579a/src/main/java/nl/appelgebakje22/eventbus/EventBus.java#L58

The registration of MyClass::myListener and MyClass::myListener won't cause an error since the runtime identity will be different each time. This will need to fixed eventually.

Storing it as a variable Consumer<MyEvent> sub = MyClass::myListener and registering the variable sub twice causes an error like expected.

dvandenham commented 4 days ago

The following tests should also be changed when this is fixed:

https://github.com/dvandenham/EventBus/blob/1c37ef09cb306cb826cfb691abb68d77f58b53d6/src/test/java/SubscriberTest.java#L88 https://github.com/dvandenham/EventBus/blob/1c37ef09cb306cb826cfb691abb68d77f58b53d6/src/test/java/SubscriberTest.java#L89