-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.lua
53 lines (41 loc) · 1.21 KB
/
main.lua
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require "iuplua"
lo = require "lockout"
lui = require "lui"
---------------------------------------------------------------------------------------------------------------
local mainViewModel = function(self)
self.counter = lo.observable(1)
self.change = function()
self.counter(self.counter() + 1)
end
self.hello = lo.computed(function()
return "Counter = " .. self.counter()
end)
self.items = lo.computed(function()
print(1)
items = {}
for i = 1, self.counter() do
items[i] = i * i
end
return items
end)
return self
end
---------------------------------------------------------------------------------------------------------------
local template = lui.dialog {
databind = { title = "counter" },
size = "QUARTERxQUARTER",
lui.vbox{
lui.button {
databind = { action = "change", title = "hello" },
},
lui.vbox {
databind = { foreach = "items" },
lui.label {
databind = { title = "_data" }
}
}
}
}
local dlg = lo.applyBindings(mainViewModel{}, template)
dlg:show()
iup.MainLoop()