diff options
| author | ewy <ewy0@protonmail.com> | 2026-05-02 17:24:31 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-05-02 17:24:31 +0200 |
| commit | 1b61ac20cf226472964111156d64d61ca6f7ac60 (patch) | |
| tree | bb87516bd6beedd63cd0f21614195efe049f2bf2 | |
| parent | 1924b93dfbed17f7f22d3c373939dcceeb753852 (diff) | |
add docs
| -rw-r--r-- | components.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/components.go b/components.go index 6f59f58..7091ad1 100644 --- a/components.go +++ b/components.go @@ -5,8 +5,11 @@ import ( "sync" ) +// ComponentList is a list wrapper type which handles operation modes of the program type ComponentList[T any] []T +// RunAsync checks components one by one and triggers the fire method in a goroutine. +// the method will return when the waitgroup is done (all initializers are finished) func (c ComponentList[T]) RunAsync(fire func(T) error) { wg := sync.WaitGroup{} for _, i := range c { @@ -20,6 +23,8 @@ func (c ComponentList[T]) RunAsync(fire func(T) error) { wg.Wait() } +// RunSync checks components one by one and fires them synchronously. +// important when the order of init matters (for example, paths needs to go before cache) func (c ComponentList[T]) RunSync(fire func(T) error) { for _, i := range c { err := fire(i) |
