miketheprogrammer / go-thrust

Cross Platform UI Kit powered by Blink/V8/Chromium Content Lib
MIT License
445 stars 34 forks source link

Implement Thrust Handler Interface #25

Closed miketheprogrammer closed 9 years ago

miketheprogrammer commented 9 years ago

Below is a raw chat log, i do not currently have time to clean up, this log describes an idea for a handler interface. will clean up as soon as possible

'Then you can kinda ignore my typed handler example above. You make a handler, the struct should include the object the handler is for, which includes the id. So your dispatcher can check for that before sending on the event chan or calling the handler method.


 if (handler.Blah.ID == event.TargetID) {
  handler.Event <- event
}

miketheprogrammer November 14 2014 Yes should we use an Interface or a Func for the argument to "Register" or "Add" tehbilly November 14 2014 Make it a small-buffered channel to not block the dispatcher, send the event on the chan in a select so you can timeout and detect hung handlers, and your handler itself ONLY has to worry about processing the event. A type. Which I'd define in the main package. type Handler struct { etc. etc. etc. miketheprogrammer November 14 2014 ah ok tehbilly November 14 2014


myHandler := thrust.NewHandler()
myHandler.Handle = funcHere
myHandler.SetSomething("blah")
thrust.AddHandler(myHandler)

That can be done with a very simple placeholder. I was going to submit a PR later with common moved to the root level. Gah, I need to go get food. It's almost time for the cafeteria to get crowded, lol. Sorry I've been rambling, hopefully the perspective helps. It's nice just being distracted from my massive refactoring and environment setup project...

miketheprogrammer commented 9 years ago

Basics Implemented, lets clean this issue up.