Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/evaera/roblox-lua-promise
Promise implementation for Roblox
https://github.com/evaera/roblox-lua-promise
lua roblox
Last synced: 3 months ago
JSON representation
Promise implementation for Roblox
- Host: GitHub
- URL: https://github.com/evaera/roblox-lua-promise
- Owner: evaera
- License: mit
- Created: 2019-09-10T04:19:52.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-16T01:33:08.000Z (about 1 year ago)
- Last Synced: 2024-04-14T06:18:28.296Z (8 months ago)
- Topics: lua, roblox
- Language: Lua
- Homepage: https://eryn.io/roblox-lua-promise/
- Size: 2.67 MB
- Stars: 265
- Watchers: 9
- Forks: 66
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-roblox - Roblox Lua Promise - Promise implementation for Roblox. (Libraries / Utility)
- awesome-roblox - Roblox Lua Promise
- awesome-roblox - Roblox Lua Promise
README
## 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