Skip to content

Instantly share code, notes, and snippets.

@MaxMorais
Created January 13, 2023 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaxMorais/18c34444541fb8d97c9208cdef1c30d1 to your computer and use it in GitHub Desktop.
Save MaxMorais/18c34444541fb8d97c9208cdef1c30d1 to your computer and use it in GitHub Desktop.
type ModelEvent struct {
Dao *daos.Dao
Model models.Model
}
func modelEventCallbackConstructor(event string) {
return func(cb func(e *core.ModelEvent)){
fmt.Println("Listening in GO for %s", event)
unsub := event.On(event, func(e *event.UnknownPayload){
core((*core.ModelEvent)(unsafe.Pointer(e)))
})
cleanup(event, unsub);
}
}
func eventCallbackConstructor(event string, *eventType any){
return func(cb func(e *eventType)){
fmt.Println("Listening in GO for %s", event)
unsub := event.On(event, func(e *event.UnknownPayload){
core((*eventType)(unsafe.Pointer(e)))
});
cleanup(event, unsub);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment