- Please make sure that in every time we mention source we mean it only for the server side of the callbacks only.
Learn more
lib.promise.on
Parameters
- name: Name of the server callback to define.
- func: Function to execute when callback is triggered (always receives
sourceas first parameter).
Receive
- return: boolean, if the callbacks successfuly defined will return true, if not it will return false.
lib.promise.await
Parameters
- debug: (default: false)
- Enable debug logging for this callback.
- Debug mode logs callback's triggers, returns, and timeouts that went during that callback's trip.
- timeout: (default: 10000)
- How much time in milliseconds to await for the client side before timing-out the callback and breaking it.
- You can ignore it to use the default time.
- name:
- Name of the registered client callback to await for.
- source: (server only)
- The client player server's ID to await from.
- ...varargs :
- Additional arguments to pass to the callback.
Receive
- Response from the oposite side.
Callouts
⚠️
- All registered callbacks are not unique identifiers for the callback, you need to pass the resource name and the side.
- e.g lib.promise.on('getData'). instead you need to define it like this: lib.promise.on('tr_kit:server:getData'). the callbacks are designed to be global and any one else can call them.
- Runtime errors are caught and logged automatically.
- Automatically handles nil returns and multiple return values.
- Awaiting from the js will not block the runtime, you need to use the native
awaitattr and synchronousing the function you are in.