Observer
Instead of rebuilding whole widget tree on Store action, it rebuilds only those in the Observer.
-- in your custom widget build method
e.Column({
SortOrder = Enum.SortOrder.Name,
Children = {
e.TextLabel("Counter example with Observer"),
e.TextButton("Increment", {
OnClick = function()
self.Controller:Commit("Increment", {})
end
}),
e.Observer( -- only widgets in this gets rebuilt on Increment
self.Controller, -- the store
{'Increment'}, -- action(s) to listen to
function()
return e.TextLabel(tostring(self.Controller.State.Counter))
end -- child builder function
)
}
})
Last updated
Was this helpful?