jarkonik / jarkonik/bevy_scriptum
`Promise:await()` method
- Dominant language
- Rust
- Stars
- 171
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
Javascript has a promise system similar to the one offered by this crate. However, it also comes with a big problem called Callback Hell, which basically looks like this:

The solution JS opted for is to introduce the `await` keyword. Since this crate is supposed to be language agnostic, it should instead add a method for that functionality.
This is important because, if you want to use more than one value from rust at a time, you would have to nest the callbacks, like so:
```lua
get_my_value1():and_then(function(value1)
get_my_value2():and_then(function(value2)
-- etc.
end)
end)
```
**Describe the solution you'd like**
With the `:await()` method, the above code should look like this. Much nicer:
```lua
local value1 = get_my_value1()
:and_then(function(value)
return value
end)
:await()
local value2 = get_my_value2()
:and_then(function(value)
return value
end)
:await()
--- etc
```
The await method should wait until the callback function returns, and then give back the final value.
**Additional context**
Nested callbacks look ugly
Contributor guide
Research direction
The issue names no files, tests, or entry points. Start by locating the crate's Promise implementation and its Lua-facing API, then determine how callback completion is currently represented. Done would require a defined Promise:await() behavior that supports the shown usage and corresponding tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100