-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Introduce the problem
LVGL already has subject/objserver available, but it's in a poor state:
- Every widget needs custom code in
lvgl/src/others/observer/lv_observer.c - Cannot create subject on the fly, it must be predefined.
- It has overlap with lv_obj_property
- C language needs lots of callbacks.
Proposal
We can use lua for the same idea.
Example of usage.
local subjectA = Subject()
local subjectB = Subject()
local obj = Object()
obj.w = subjectA
obj.h = Subject({subjectA, subjectB}, calculate = function(subjects)
return subjects[0] + subjects[1]
end
)
subjectA.value = 123Under the hood, we monitor the value of a property set to obj in obj.__newindex meta method, bind the property to a subject.
Also monitor subject.__newindex meta method, call the obj.set method with subject's actual value.
Metadata
Metadata
Assignees
Labels
No labels