Quantcast
WoWInterface - View Single Post - Scorpio.UI - a new ui & skin system
View Single Post
08-05-20, 12:03 AM   #6
kurapica.igas
A Flamescale Wyrmkin
Join Date: Aug 2011
Posts: 141
A new system is added to apply dynamic values to the ui styles:

Click image for larger version

Name:	reactive.jpg
Views:	129
Size:	54.8 KB
ID:	9464

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:
  1. 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.
  Reply With Quote