Skip to content

Commit

Permalink
adding RegisterChannelsLength convenience method
Browse files Browse the repository at this point in the history
  • Loading branch information
ineiti committed Jan 23, 2018
1 parent 8db2a54 commit 5f0d9c4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions treenode.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,18 @@ func (n *TreeNodeInstance) RegisterChannels(channels ...interface{}) error {
return nil
}

// RegisterChannelsLength is a convenience function to register a vararg of
// channels with a given length.
func (n *TreeNodeInstance) RegisterChannelsLength(length int, channels ...interface{}) error {
for _, ch := range channels {
if err := n.RegisterChannelLength(ch, length); err != nil {
return fmt.Errorf("Error, could not register channel %T: %s",
ch, err.Error())
}
}
return nil
}

// RegisterHandler takes a function which takes a struct as argument that contains two
// elements: a TreeNode and a message. It will send every message that are the
// same type to this channel.
Expand Down

0 comments on commit 5f0d9c4

Please sign in to comment.