MCPcopy
hub / github.com/lxn/walk / newReflectListModel

Function newReflectListModel

reflectmodels.go:33–77  ·  view source on GitHub ↗
(dataSource interface{})

Source from the content-addressed store, hash-verified

31}
32
33func newReflectListModel(dataSource interface{}) (ListModel, error) {
34 items, err := itemsFromReflectModelDataSource(dataSource, "ReflectListModel")
35 if err != nil {
36 return nil, err
37 }
38
39 m := &reflectListModel{
40 dataSource: dataSource,
41 items: items,
42 value: reflect.ValueOf(items),
43 }
44
45 if rlm, ok := dataSource.(ReflectListModel); ok {
46 rlm.setValueFunc(func(index int) interface{} {
47 return m.Value(index)
48 })
49
50 rlm.ItemChanged().Attach(func(index int) {
51 m.PublishItemChanged(index)
52 })
53
54 rlm.ItemsReset().Attach(func() {
55 m.items = rlm.Items()
56 m.value = reflect.ValueOf(m.items)
57
58 m.PublishItemsReset()
59 })
60
61 rlm.ItemsInserted().Attach(func(from, to int) {
62 m.items = rlm.Items()
63 m.value = reflect.ValueOf(m.items)
64
65 m.PublishItemsInserted(from, to)
66 })
67
68 rlm.ItemsRemoved().Attach(func(from, to int) {
69 m.items = rlm.Items()
70 m.value = reflect.ValueOf(m.items)
71
72 m.PublishItemsRemoved(from, to)
73 })
74 }
75
76 return m, nil
77}
78
79func (m *reflectListModel) setBindingMember(member string) {
80 m.bindingMember = member

Callers 2

SetModelMethod · 0.85
SetModelMethod · 0.85

Calls 13

ValueMethod · 0.95
PublishItemsInsertedMethod · 0.80
PublishItemsRemovedMethod · 0.80
setValueFuncMethod · 0.65
ItemChangedMethod · 0.65
ItemsResetMethod · 0.65
ItemsMethod · 0.65
ItemsInsertedMethod · 0.65
ItemsRemovedMethod · 0.65
AttachMethod · 0.45
PublishItemChangedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…