
This is the de facto Promise implementation for Roblox. Async code with callbacks gets messy fast, and promises give you composable, cancellable async operations with proper error handling. Many popular libraries build on top of it.
What is roblox-lua-promise?
Promise implementation for Roblox
An implementation of Promise similar to Promise/A+. The way Roblox models asynchronous operations by default is by yielding (stopping) the thread and then resuming it when the future value is available. This model is not ideal because: - Functions you call can yield without warning, or only yield sometimes, leading to unpredictable and surprising results. Accidentally yielding the thread is the source of a large class of bugs and race conditions that Roblox developers run into. - It is difficult to deal with running multiple asynchronous operations concurrently and then retrieve all of their values at the end without extraneous machinery. - When an asynchronous operation fails or an error is encountered, Lua functions usually either raise an error or return a success value followed by the actual value. Both of these methods lead to repeating the same tired patterns many times over for checking if the operation was successful. - Yielding lacks easy access to introspection and the ability to cancel an operation if the value is no longer needed. This Promise implementation attempts to satisfy these traits: An object that represents a unit of asynchronous work
The facts, straight from GitHub
- Repository: evaera/roblox-lua-promise
- 349 stars and 85 forks, with 14 open issues
- Written mainly in Lua
- Licensed under MIT
- Started in 2019, last updated 2024-08-06
Grab it with: git clone https://github.com/evaera/roblox-lua-promise.git
Check the README for how to install: most Roblox projects are distributed through Wally or as rbxm models you drop into Studio.
Frequently asked questions
Is roblox-lua-promise free to use?
It is released under the MIT license, so it is free to use. Read the license text for the exact terms before you ship anything based on it.
Is the project still maintained?
Development has slowed down: the last push was on 2024-08-06. The code is still valuable as reference, and forks may carry the work forward.
What do I need to know before diving in?
The project is written mainly in Lua, so some familiarity there helps a lot. Start with the README, then browse the open issues to see what the rough edges are. That is usually the fastest way to understand the real state of any repository.
Where do I get help if I am stuck?
Open an issue on the GitHub issue tracker, check existing discussions, and of course post right here in this topic. Someone in the Roblox community has probably hit the same wall before you.
Over to you
Have you tried roblox-lua-promise? Are you running it, forking it, or did you rage quit halfway through the setup? Reply below with your experience, your questions or your own favorite alternative. If there is enough interest we can put together a community guide for it.