Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Pass functions to register method from inputs instead of methods #90

Merged
merged 1 commit into from
Jul 13, 2019
Merged

Pass functions to register method from inputs instead of methods #90

merged 1 commit into from
Jul 13, 2019

Conversation

hlxid
Copy link
Member

@hlxid hlxid commented Jul 13, 2019

Finishes fix of #89.

The problem was that we passed methods to the register/unregister methods, which take functions. In these cases scala will convert the methods to anonymous functions e.g. in the TwitchChatInput start part onMessage will get changed to x => onMessage(x). Because of this the function passed in the start method is not the exact same object as the one in the stop method, the handler of the input wasn't removed in the connector.

Note that I only have tested this with the twitch chat input, but the handler logic similar in all other connectors it should work there too.

In the future we probably want to generalize connectors that have event handlers with some trait. Then we could place a implicit identifier in the inputs and have the connector unregister all handlers that were registered with a identifier when the plugin stops. Thats a way cleaner solution, but will require more time, so this is just for the 2.1 hotfix.

@J0B10
Copy link
Member

J0B10 commented Jul 13, 2019

Wow, that was quick, thank you 👍

@J0B10 J0B10 merged commit 70956ce into codeoverflow-org:hotfix/0.2.1-prealpha Jul 13, 2019
@hlxid hlxid deleted the fix/89-handler-called-twice branch July 13, 2019 18:15
@hlxid hlxid mentioned this pull request Aug 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants