ChrisMAN Posted October 21, 2012 Posted October 21, 2012 Last week I wrote an emitter for doing easy events on objects. This week I wrote a library for handling deferred values. This is really nice for doing asynchronous programming. These 2 components are all that I really need to do async/evented programming. https://github.com/friesencr/lua_promise Promises are one of those things that are so elemental / simple they can be hard to grasp. Here is a small example of what I might use it for. function UsePotion() SelectPotion() :done(function(potion) NomNom(potion) end) end function SelectPotion() local p = Promise:new() gui = LoadPotionGui() gui:on('select_potion', function() p:resolve(gui.selected_potion) end) return p end Peace, Chris 2 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.