> For the complete documentation index, see [llms.txt](https://thebuildex.gitbook.io/enoria/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://thebuildex.gitbook.io/enoria/state-management/observer.md).

# Observer

Instead of rebuilding whole widget tree on Store action, it rebuilds only those in the Observer.

```lua
-- 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
      )
   }
})
```
