aboutsummaryrefslogtreecommitdiff
path: root/opts.go
blob: 905c1934e5ea262ce1abdaf2889b047d6c03b013 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package eventbus

type Opt interface {
	Apply(b *Bus)
}

// NameSeparator sets the event name separator (default ".").
type NameSeparator string

func (n NameSeparator) Apply(b *Bus) {
	b.nameSeparator = string(n)
}

// Wildcard  sets the wildcard character for subscriptions (default "*").
type Wildcard string

func (w Wildcard) Apply(b *Bus) {
	b.wildcard = string(w)
}

// Capacity sets the initial capacity for listeners trie (default 32).
type Capacity int

func (c Capacity) Apply(b *Bus) {
	b.listeners = node[Listener]{
		children: make(map[string]*node[Listener], c),
		values:   make([]Listener, 0, c),
	}
}