A new system is added to apply dynamic values to the ui styles:
The text of the label will be changed based on the player's health.
The real code of the
Wow.UnitHealth("player") is
Lua Code:
FromEvent("UNIT_HEALTH"):FirstMatch(unit):Map(_G.UnitHealth)
The
FromEvent can bind any system events as a data source, the FirstMatch is a filter to check the first event argument, and then we use the Map to convert the unit to its health.
All those methods will return the same value based on the parameter, so the
FromEvent("UNIT_HEALTH") will return the same object for any calls.
This is be done with the observable pattern, you may check the
PLoop/022.reactive.md or
http://reactivex.io/ for more details. This is a little hard for common authors, so you may leave the details to me.
Like the Wow.UnitHealth, I'll try to provide enough APIs for most case.