~sircmpwn/aerc

ref: 0.1.1 aerc/lib/ui/invalidatable.go -rw-r--r-- 344 bytes
eabdcff8Jonas Kalderstam Added config file to Make clean 1 year, 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package ui

import (
	"sync/atomic"
)

type Invalidatable struct {
	onInvalidate atomic.Value
}

func (i *Invalidatable) OnInvalidate(f func(d Drawable)) {
	i.onInvalidate.Store(f)
}

func (i *Invalidatable) DoInvalidate(d Drawable) {
	v := i.onInvalidate.Load()
	if v == nil {
		return
	}
	f := v.(func(d Drawable))
	if f != nil {
		f(d)
	}
}