From b7fad684386709ca16170a3088bfde15d88c2c41 Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Fri, 18 Oct 2024 19:02:19 +0800 Subject: [PATCH] better doc --- docs/apidoc/promisify.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/apidoc/promisify.md b/docs/apidoc/promisify.md index e19fac7..46dd7ec 100644 --- a/docs/apidoc/promisify.md +++ b/docs/apidoc/promisify.md @@ -23,4 +23,15 @@ ModAPI.addEventListener("sendchatmessage", function downloadSomething(e) { }); ``` +The way this promisify method works is by taking in a java method, and (effectively) converting it into a javascript async function. +For example, you can do: +```javascript +var asyncDownloadRemoteURI = ModAPI.promisify(ModAPI.hooks.methods.nlevi_PlatformRuntime_downloadRemoteURI); + +console.log(typeof asyncDownloadRemoteURI); //Logs function +``` + +When it is called, like any other asyncronoush function, it returns a `Promise` object. +https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise + You can replace the argument with any other method or constructor, including non asynchronous ones. \ No newline at end of file