1
0
Fork 0
mirror of https://github.com/Luzifer/wasm-openssl.git synced 2024-11-08 14:50:10 +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)
}