mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-12-03 20:32:55 +00:00
Handler: Added examples as comments for documentation
This commit is contained in:
parent
18024526fe
commit
cb8567f006
|
@ -167,6 +167,9 @@ func (h *Handler) ChanFor(fn func(interface{}) bool) (out <-chan interface{}, ca
|
||||||
// A handler can be a function with a single argument that is the expected event
|
// A handler can be a function with a single argument that is the expected event
|
||||||
// type. It must not have any returns or any other number of arguments.
|
// type. It must not have any returns or any other number of arguments.
|
||||||
//
|
//
|
||||||
|
// // An example of a valid function handler.
|
||||||
|
// h.AddHandler(func(*gateway.MessageCreateEvent) {})
|
||||||
|
//
|
||||||
// Channel
|
// Channel
|
||||||
//
|
//
|
||||||
// A handler can also be a channel. The underlying type that the channel wraps
|
// A handler can also be a channel. The underlying type that the channel wraps
|
||||||
|
@ -176,6 +179,11 @@ func (h *Handler) ChanFor(fn func(interface{}) bool) (out <-chan interface{}, ca
|
||||||
// Keep in mind that the user must NOT close the channel. In fact, the channel
|
// Keep in mind that the user must NOT close the channel. In fact, the channel
|
||||||
// should not be closed at all. The caller function WILL PANIC if the channel is
|
// should not be closed at all. The caller function WILL PANIC if the channel is
|
||||||
// closed!
|
// closed!
|
||||||
|
//
|
||||||
|
// // An example of a valid channel handler.
|
||||||
|
// ch := make(chan *gateway.MessageCreateEvent)
|
||||||
|
// h.AddHandler(ch)
|
||||||
|
//
|
||||||
func (h *Handler) AddHandler(handler interface{}) (rm func()) {
|
func (h *Handler) AddHandler(handler interface{}) (rm func()) {
|
||||||
rm, err := h.addHandler(handler)
|
rm, err := h.addHandler(handler)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue