mikestefanello / hooks Goto Github PK
View Code? Open in Web Editor NEWSimple, type-safe hook system to enable easier modularization of your Go code.
License: MIT License
Simple, type-safe hook system to enable easier modularization of your Go code.
License: MIT License
This lib looks great and promising. However my project includes multiple services running in separate processes, or even separate devices in future. Would love to see this lib to have network support.
Cheers.
Hello!
Neat project. While I was reading, I noticed this example:
HookUserPreInsert.Listen(func(e hooks.Event[user.User]) {
// Change the user's name
e.Msg.Name = fmt.Sprintf("%s-changed", e.Msg.Name)
})
Shouldn't this be of type hooks.Event[*user.User]
? Since your other PreInsert is using *User
.
But I might be wrong. :)
Minor issue but having the nil check in the logf function means every call has to setup a call stack, evaluate parameters, and perform the call even if logger is nil. This is most noticeable in the dispatch function, which might be called repeatedly in a tighter loop. Would moving the nil test outside logf to surround the calls be appropriate?
ex:
if logger != nil {
logf("dispatching hook %s to %d listeners (async: %v)", h.GetName(), len(h.listeners), async)
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.