-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IndirectPromise
seems to become undefined
in the compiled code
#2
Comments
IndirectPromise
seems to become undefined
in my codebaseIndirectPromise
seems to become undefined
in the compiled code
Your code looks fine, my guess is that the build isn't including the dependencies in the final output. I assume you're just doing I'm not very familiar with the details of using ocamlfind+ocamlc+js_of_ocaml directly, could you try using Dune to build your program? It what we use in the VSCode extension, which includes promise_jsoo successfully. Writing this in a
Afterwards, you can do Expand Me
//# 1 "bg.bc.runtime.js"
// Generated by js_of_ocaml 3.8.0
(function(joo_global_object)
{joo_global_object.IndirectPromise
=
function(promise){this.underlying = promise};
joo_global_object.IndirectPromise.wrap
=
function(value)
{return value
!==
undefined
&&
value
!==
null
&&
typeof value.then
===
"function"
?new IndirectPromise(value)
:value};
joo_global_object.IndirectPromise.unwrap
=
function(value)
{return value instanceof joo_global_object.IndirectPromise
?value.underlying
:value}}
(function(){return this}())); |
That was it. For now, dune works. Though even its |
Great! Glad you got it working. |
Note that I have barely spent a couple of days on OCaml, let alone on
jsoo
orpromise_jsoo
. So forgive me for any stupid mistakes or poor code conventions.Preface: I am writing a Firefox WebExtension using
jsoo
. To work smoothly with the Promise-dominant WE API, I opted forpromise_jsoo
.On running the compiled code, I see an error
ax is undefined bg.js:542
, wherebg.js
is the compiled file spit byjsoo
. The working of theax
variable is as follows:If you notice,
ax
is set to beIndirectPromise
. Thereafter, accessing it (most likely) inax.wrap
results inundefined
error.Are you aware why this might be happening?
For reference, following is the relevant portion of OCaml code:
useDocumentFonts##set
returns a Promise as documented here:I tried the
let*
binding too:but in this case, the 'then' part of the code, or the 'in' part of the code where,
console.log
should print, is never invoked. So no error, but nothing else happens too.Note that the
useDocumentFonts##set dont_use_document_fonts
actually works in both cases - I can see the relevant Firefox config value changing. Its just thethen
part that seems problematic.Compile command:
I read the
Promise
section of your blog https://mnxn.github.io/blog/ocaml/vscode-jsoo/, which makes me think that I am doing something wrong in terms ofwrap
andunwrap
.The text was updated successfully, but these errors were encountered: