• 0 Posts
  • 44 Comments
Joined 4 years ago
cake
Cake day: February 17th, 2021

help-circle



  • I think what you have is the perfect amount of complexity, and easily extendable. I use callbacks like this all the time in my code, but also my users are part of my team at work so they don’t have far for help when the callback API isnt clear :P most of my users dont even know callbacks are a thing.

    If your list of supported events gets large or you want to cheaply support future changes to the server, you could pass all event names and data through a handler callback and make users handle multiple event types.

    One of the things that makes plain callbacks nice is it’s an easy way to let your users decide how they want to integrate with your library. If your callbacks are called from a background thread, it’s up to the user to figure out how they want to pass the event to other threads. Async users can use their runtime of choice to submit tasks from a callback.