forked from google/gxui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadapter_base.go
35 lines (29 loc) · 860 Bytes
/
adapter_base.go
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
30
31
32
33
34
35
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package gxui
type AdapterBase struct {
onDataChanged, onDataReplaced Event
}
func (a *AdapterBase) DataChanged(recreateControls bool) {
if a.onDataChanged != nil {
a.onDataChanged.Fire(recreateControls)
}
}
func (a *AdapterBase) DataReplaced() {
if a.onDataReplaced != nil {
a.onDataReplaced.Fire()
}
}
func (a *AdapterBase) OnDataChanged(f func(recreateControls bool)) EventSubscription {
if a.onDataChanged == nil {
a.onDataChanged = CreateEvent(func(bool) {})
}
return a.onDataChanged.Listen(f)
}
func (a *AdapterBase) OnDataReplaced(f func()) EventSubscription {
if a.onDataReplaced == nil {
a.onDataReplaced = CreateEvent(func() {})
}
return a.onDataReplaced.Listen(f)
}