1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-discord.git synced 2024-12-27 14:27:43 +00:00
cchat-discord/internal/funcutil/funcutil.go

20 lines
439 B
Go
Raw Normal View History

2020-09-08 04:44:09 +00:00
package funcutil
// NweCancels creates a stateful closure for adding callbacks into a list.
func NewCancels() func(...func()) []func() {
var cancels []func()
return func(appended ...func()) []func() {
cancels = append(cancels, appended...)
return cancels
}
}
// JoinCancels joins multiple cancel callbacks into one.
func JoinCancels(cancellers ...func()) func() {
2020-09-08 04:44:09 +00:00
return func() {
for _, c := range cancellers {
c()
}
}
}