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] 
> <javascript:>> 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] <javascript:>.
>> 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/1fdb81d0-afc3-41de-a425-514a3f1484df%40googlegroups.com.

Reply via email to