samber / do

⚙️ A dependency injection toolkit based on Go 1.18+ Generics.
https://pkg.go.dev/github.com/samber/do
MIT License
1.82k stars 75 forks source link

Transform hooks into slices of hooks #71

Closed samber closed 4 months ago

samber commented 5 months ago

We should be able to add multiple callbacks for each hook:

type InjectorOpts struct {
    HookAfterRegistration []func(scope *Scope, serviceName string)
    HookAfterShutdown     []func(scope *Scope, serviceName string)
        Logf                  []func(format string, args ...any)
}

instead of

type InjectorOpts struct {
    HookAfterRegistration func(scope *Scope, serviceName string)
    HookAfterShutdown     func(scope *Scope, serviceName string)
        Logf                  func(format string, args ...any)
}

Requirement for #70

samber commented 4 months ago