https://github.com/manuel-di-iorio/gm-promise
Promise implementation for Game Maker Studio 2
https://github.com/manuel-di-iorio/gm-promise
Last synced: 3 months ago
JSON representation
Promise implementation for Game Maker Studio 2
- Host: GitHub
- URL: https://github.com/manuel-di-iorio/gm-promise
- Owner: manuel-di-iorio
- Created: 2022-01-21T14:07:00.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-21T14:21:13.000Z (over 3 years ago)
- Last Synced: 2025-01-24T14:22:09.156Z (5 months ago)
- Language: Yacc
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Promise implementation for Game Maker Studio 2
Adds the support for a similar Promise implementation on GMS 2 through the usage of struct constructors and callbacks arrays.
Example:
```gml
// Execute the first HTTP call
scr_make_api_call("https://jsonplaceholder.typicode.com/todos/1")// With the .next() function, this second HTTP request will be automatically executed after the response of the previous one
.next(function(todo_resp) {
show_debug_message(todo_resp); // { "userId": 1, "id": 1, "title": "delectus aut autem", "completed": false }// As you can see, promises can be returned to create a chain of requests:
return scr_make_api_call("https://jsonplaceholder.typicode.com/todos/2");
}).next(show_debug_message) // { "userId": 1, "id": 2, "title": "quis ut nam facilis et officia qui", "completed": false }
// Catch errors (executed when calling the promise.reject() method)
.error(show_debug_message);
```## APIs
promise.next()
promise.error()
promise.resolve()
promise.reject()
## LICENSE
MIT