3 ms·
Go-trigger
- jaytaylor 11y agoNeat idea, thanks for posting this! I readily admit I'm absolutely guilty of implementing this sort pattern repeatedly across many go apps, and haven't ever [yet] gotten to making a generic implementation :) Some interesting notes (with a few curiosities): * This reminds me a lot of how jinzhu implemented the gorm [0] callbacks system. * The triggering is all global rather than per-instance (you can't create a new "trigger" struct). I wonder why this pattern was selected rather than allowing more fine-grained control and groups via instances. * Looking at the open PRs, #1 [1] was a surprise: Adding multiple listeners to one event enhancement Does go-trigger really not support multiple subscribers to an event? I wonder why it wasn't architected that way from the start. [0] https://github.com/jinzhu/gorm https://github.com/jinzhu/gorm [1] https://github.com/sadlil/go-trigger/pull/1 https://github.com/sadlil/go-trigger/pull/1
- go-down 11y agoPoints noted. The idea was to keep this thing completely simple. Per instance struct gives a complexity to carried out the instance when it is needed. so by using global this kept simple. same goes for the "Adding multiple listeners to one event enhancement". multiple listener means multiple call params. the authors couldn't desided how this will be handled. hope those features will be added real soon.