initial commit
This commit is contained in:
11
forward.go
Normal file
11
forward.go
Normal file
@ -0,0 +1,11 @@
|
||||
package channel
|
||||
|
||||
// Forward reads all values from all sources and sends them to target.
|
||||
// It blocks until all values are forwarded and the out channel was closed.
|
||||
// Use with go keyword for non-blocking behavior
|
||||
func Forward[T any](target chan<- T, sources ...<-chan T) {
|
||||
for value := range Merge(sources...) {
|
||||
target <- value
|
||||
}
|
||||
close(target)
|
||||
}
|
Reference in New Issue
Block a user