Typesafe Promise implementation for Roblox Luau
Find a file
2022-10-24 20:25:22 -06:00
docs Fix docs typo 2022-01-03 17:16:14 -05:00
lib Initial forked version 2022-10-24 20:14:27 -06:00
modules Update testez 2020-07-10 23:45:10 -04:00
.editorconfig Initial dump 2018-01-25 17:21:58 -08:00
.gitignore Initial forked version 2022-10-24 20:14:27 -06:00
.gitmodules Remove unused files 2020-05-04 22:07:36 -04:00
aftman.toml Initial forked version 2022-10-24 20:14:27 -06:00
CHANGELOG.md Initial forked version 2022-10-24 20:14:27 -06:00
default.project.json Fix default.project.json to allow usage as submodule (#29) 2021-03-19 18:50:11 -04:00
LICENSE Initial forked version 2022-10-24 20:14:27 -06:00
moonwave.toml Update discord server 2021-10-23 15:52:30 -04:00
README.md Update README.md 2022-10-24 20:25:22 -06:00
runTests.server.lua Update testez 2020-05-04 22:07:55 -04:00
test.project.json Fix default.project.json to allow usage as submodule (#29) 2021-03-19 18:50:11 -04:00
testez.toml Move to selene from luacheck 2021-12-27 21:37:04 -05:00
wally.toml Initial forked version 2022-10-24 20:14:27 -06:00

Roblox Luau Promise

An implementation of Promise similar to Promise/A+.

View docs

Why you should use Promises

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
  • Composability
  • Predictable timing

FORKED VERSION

This is a forked version of Evaera's Promise library with type annotations added to allow this library to be used in a strict-mode Luau project. Type annotations are imperfect due to limitations with the Luau language, but should at least cover intellisense and basic static analysis.

Please notify me through the issues section if any issues are encountered related to type safety or crashes. Otherwise, please send any issues related to runtime behavior to the original repository, being mindful of differences between this library and the original library.