1
0
mirror of https://github.com/Luzifer/wasm-openssl.git synced 2024-09-18 23:42:57 +00:00

Fix: If opensslLoaded function is undefined don't call it

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-09-18 19:01:52 +02:00
parent d58104a492
commit a8cdcde89a
Signed by: luzifer
GPG Key ID: DC2729FDD34BE99E
2 changed files with 5 additions and 2 deletions

View File

@ -35,7 +35,7 @@ Afterwards in your HTML you can include the `wasm_exec.js` and load the binary:
</html>
```
Be sure to have a top-level function `opensslLoaded()` defined as this will be called in the initialization of the `openssl.wasm`. This serves as a notification you do have now access to the top-level functions `encrypt` and `decrypt`:
If you have a top-level function `opensslLoaded()` defined, this will be called in the initialization of the `openssl.wasm`. This serves as a notification you do have now access to the top-level functions `encrypt` and `decrypt`:
```javascript
function decrypt(ciphertext, passphrase, callback) {}

View File

@ -12,7 +12,10 @@ func main() {
js.Global().Set("encrypt", js.NewCallback(encrypt))
// Trigger custom "event"
js.Global().Call("opensslLoaded")
if js.Global().Get("opensslLoaded").Type() == js.TypeFunction {
js.Global().Call("opensslLoaded")
}
<-make(chan struct{}, 0)
}