예제 #1
0
파일: window.go 프로젝트: dzyk/dcoin-go
/*
Binding Event Handlers are a bit different than global thrust handlers.
The Signature of the function you pass in is WindowEventHandler
*/
func (w *Window) HandleEvent(event string, fn interface{}) (events.ThrustEventHandler, error) {
	if fn, ok := fn.(func(CommandResponse, *Window)); ok == true {
		return events.NewHandler(event, func(cr CommandResponse) {
			fn(cr, w)
		})
	}
	if fn, ok := fn.(func(EventResult, *Window)); ok == true {
		return events.NewHandler(event, func(er EventResult) {
			fn(er, w)
		})
	}
	return events.ThrustEventHandler{}, errors.New("Function Signature Invalid")
}
예제 #2
0
파일: thrust.go 프로젝트: dzyk/dcoin-go
/*
Create a new EventHandler for a give event.
*/
func NewEventHandler(event string, fn interface{}) (events.ThrustEventHandler, error) {
	return events.NewHandler(event, fn)
}