Usman Mughal
Usman Mughal

Reputation: 211

Property observers in Lua

Is there way to add a property observer in Lua just like Swift does for WillSet and DidSet with properties?

For example, I have a object of display.newText and whenever I change it's text property. I need to do something other as well? Like object.text = "Changed"

I know I can add a method like setText() or something but I'm looking for property observers in Lua language.

Thanks in advance.

Upvotes: 1

Views: 314

Answers (1)

lhf
lhf

Reputation: 72352

Use a proxy table. This is explained in Pil, Chapter 13.

Upvotes: 3

Related Questions