-
Posted by Myrroddin on Tue, 15 Nov 2011 16:32:12
Mr. Whitehead,
I have been working on converting LibDataBroker from WoW to Rift, and thus far, it is going very well. The two major hurdles have been removing LibStub and CallbackHandler as dependencies. LibStub's removal was the easy part, as Rift does version checking inherently. Removing CallbackHandler has been tricky.
For reference, a pastebin of WoW-LDB. And my work in progress pastebin. By comparing the two, it is easy to see the relatively minor changes.
Since Rift's API system is reasonably close to basic Lua, with necessary Rift-centric changes, I would think the conversion would be simple. As inspiration on how to write a library for Rift, I look to the main API developer, who wrote LibUnitChange. pastebin provided.
Rift's equivalent to CallbackHandler is called Utility.Event.Create() and has the same intent. Here is the official documentation in Wiki format. The example code and what is used in LibUnitChange don't match, and that's where I need help.
I know how the Rift event handler works, how to register and process events. I wrote the Wiki on how it is done. But I am struggling with Utility.Event.Create() in relation to my conversion.
My code, as you can see from the link above, is missing a return value, and I'd bet that breaks the whole thing. What do you make of the Utility documentation, and what am I not understanding?
Unrelated to me trying to figure out how the Utility works, I have noticed a trend, starting with LibUnitChange and continuing to other people's library files. The code block
if not Library then Library = {} end if not Library.LibUnitChange then Library.LibUnitChange = {} end
I am not using that. Again, since there is no LibStub, this is one of a few ways to make the lib's API available globally. Any thoughts on whether I should follow suit?
Oh, on a completely side note, several people have been looking at Clique to convert to Rift. It seems to be in the top three most requested addons.
Regards, Myrroddin
-
Posted by jnwhiteh on Wed, 16 Nov 2011 12:43:28
I'm not sure I see anything immediately that is wrong/a problem but admittedly I'm not looking at it very deep. I don't really have much time right now to dig into another API. If you can ask specific questions related to small snippets of code I can definitely help out there.