add remove driver function

This commit is contained in:
Adrian Zuercher
2025-07-30 11:55:30 +02:00
parent e720f0d2d3
commit a39dcc06f4
3 changed files with 84 additions and 2 deletions

View File

@@ -16,9 +16,7 @@ func (b *Bus) AddAddress(address ...uint) {
}
b.Address = append(b.Address, a)
slices.Sort(b.Address)
}
}
func (b *Bus) AddSubscription(sub ...string) {
@@ -34,3 +32,25 @@ func (b *Bus) AddPublish(pub ...string) {
}
b.Topic.AddPublish(pub...)
}
func (b *Bus) RemoveAddress(address ...uint) {
if len(b.Address) == 1 {
b.Address = []uint{}
return
}
for _, toDelete := range address {
for i, a := range b.Address {
if a == toDelete {
b.Address = slices.Delete(b.Address, i, i+1)
}
}
}
}
func (b *Bus) RemoveSubscription(sub ...string) {
b.Topic.RemoveSubscription(sub...)
}
func (b *Bus) RemovePublish(pub ...string) {
b.Topic.RemovePublish(pub...)
}