Documentation
¶
Overview ¶
Package goevent is event dispatcher.
Listen for event:
e := goevent.New()
e.On(func(i int, s string){
fmt.Printf("%d: %s\n", i, s)
})
Trigger:
e.Trigger(1, "foo")
Use event table:
table := goevent.NewTable()
table.On("foo", func(i int){
fmt.Printf("foo: %d\n", i)
})
table.On("bar", func(s string){
fmt.Printf("bar: %s\n", s)
})
table.Trigger("foo", 1)
table.Trigger("bar", "hoge")
table.Trigger("bar", 38) // retrun error
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event interface {
Trigger(args ...interface{}) error
// f is a function
On(f interface{}) error
Off(f interface{}) error
}
Event is an event.
type EventNotDefined ¶
type EventNotDefined struct {
// contains filtered or unexported fields
}
EventNotDefined is an error indicationg that the event has not been defined.
func (*EventNotDefined) Error ¶
func (e *EventNotDefined) Error() string
func (*EventNotDefined) EventName ¶
func (e *EventNotDefined) EventName() string
EventName return name of the event.
Click to show internal directories.
Click to hide internal directories.