Skip to content

Commit

Permalink
better doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ZXMushroom63 committed Oct 18, 2024
1 parent 8a6553f commit b7fad68
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/apidoc/promisify.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit b7fad68

Please sign in to comment.