museun / twitchchat

interface to the irc portion of Twitch's chat
Apache License 2.0
103 stars 23 forks source link

Examples: remove repetetive functions #203

Closed Horki closed 4 years ago

Horki commented 4 years ago

@museun please test #202

museun commented 4 years ago

Thanks, I'll take a look at it in a bit. I've been meaning to touch up the examples and add more -- then realized they were mostly the same and never got around to de-duplicating it.

museun commented 4 years ago

Thinking about it, I do sort of like the idea that you can just copy/paste an example and it just works.

But, these helper functions do make it easier to read the code. I would rather have handle_message() in each example, though, because its a very core idea. This function is 'verbose' intentionally so you can see all of the enum variants for the message types.

If we do move it 'include' then the main_loop() could also be moved into it with that function inlined into the body.

Horki commented 4 years ago

@museun they are still visible, even when pasted into include/mod; IMHO main_loop is core of example, rest isn't