Skip to content

Instantly share code, notes, and snippets.

@shixzie
Created July 29, 2017 04:07
Show Gist options
  • Save shixzie/6bf6aa8da79d7e62347c12e6e2dfacbc to your computer and use it in GitHub Desktop.
Save shixzie/6bf6aa8da79d7e62347c12e6e2dfacbc to your computer and use it in GitHub Desktop.
func handlerForInterface(handler interface{}) EventHandler {
switch v := handler.(type) {
case func(*Session, interface{}):
return interfaceEventHandler(v)
case func(*Session, *ChannelCreate):
return channelCreateEventHandler(v)
case func(*Session, *ChannelDelete):
return channelDeleteEventHandler(v)
case func(*Session, *ChannelPinsUpdate):
return channelPinsUpdateEventHandler(v)
case func(*Session, *ChannelUpdate):
return channelUpdateEventHandler(v)
case func(*Session, *Connect):
return connectEventHandler(v)
case func(*Session, *Disconnect):
return disconnectEventHandler(v)
// . . . 37 more cases below
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment