I think I solved my issue : (based on [this](
https://github.com/RagulanDev/QFace/blob/665add980903374f3e174bc9a17d560890586ed1/src/cpp/main.cpp
))

// I can get result["whatever"], or add parameters, depending on the 
> expected callback
> void print(val result)
> {
>   std::cout << "Hi there..." << "\n";
> }
>
> int main()
> {
>   val prom
>   promise.call<void>("then", val::module_property("Zecallback"));
>   return 0;
> }
> EMSCRIPTEN_BINDINGS(name) {
>   function("Zecallback", &print);
> }
>
> couldn't reproduce the bug though, will post it when it pops back.
>
 
On Tuesday, November 26, 2019 at 4:42:13 PM UTC+1, Mehdi Sabwat wrote:
>
> I have a JS call that returns a promise. for example : 
>
> createAudioFileAsync(audioSettings).then(successCallback);
>
> I don't want to use emscripten_async_call because I don't know when the 
> promise will be resolved.
>
> I tried to val.call<>("then", ...); but I am running into a clang bug.
>
> On Monday, November 25, 2019 at 8:03:41 PM UTC+1, Brion Vibber wrote:
>>
>> Are you trying to create a C++ function that schedules work 
>> asynchronously and synchronously returns a Promise which can be used by JS 
>> code to wait on and retrieve a value?
>>
>> This should be possible through emscripten::val by translating the 
>> equivalent code from JS to val invocations, though I've not tested it... 
>> You'd still need to use emscripten_async_call unless there's some other way 
>> you intend to schedule the work to happen after the call, such as manual 
>> use of setTimeout via val or some other callback.
>>
>> -- brion
>>
>> On Mon, Nov 25, 2019 at 10:03 AM Mehdi Sabwat <[email protected]> wrote:
>>
>>> Hi, 
>>>
>>> I have been looking for a way to resolve a Promise using 
>>> emscripten::val, is that possible? if not, would it be possible in  C/C++ 
>>> without wrapping it in an EM_ASM?
>>>
>>> I have been thinking about Atomics.wait, but I am not sure it is the 
>>> best way because it is limited to Int32Array. For now, I am using 
>>> emscripten_async_call(), it would be great if I could replace it with 
>>> something less hacky.
>>>
>>> Thanks
>>>
>>> Mehdi
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "emscripten-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/emscripten-discuss/978f8d00-0cf1-4dec-bbe5-b9c7b20a1a61%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/emscripten-discuss/978f8d00-0cf1-4dec-bbe5-b9c7b20a1a61%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/25e77775-3606-4176-a6a2-fd87962b2c1a%40googlegroups.com.

Reply via email to