We have moved to a new Sailfish OS Forum. Please start new discussions there.

How to use JavaScript promises in QML [answered]

asked 2019-03-19 16:26:42 +0300

pawel gravatar image

updated 2019-03-20 00:19:02 +0300

Maus gravatar image


i would like to use promises in my java script code / qml any idea how to do that ? or where i can find an example ?

Thanks !

to be more.precise: new.Promise() in sdk, it will not.work, cause promise is unknown. i expected it to be part of the language

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by pawel
close date 2019-03-20 10:56:36.803269


Erm, Google?

Edz ( 2019-03-19 18:14:18 +0300 )edit

you know this is what makes me wanting to delete my repos.

i am not.asking how to use them, but what i need to make them work in qt/sdk

and i did search the internet before

ach this is so boring

pawel ( 2019-03-19 19:35:07 +0300 )edit

Here are no moderators who can warn edz about his answers?

strobovalo ( 2019-03-19 23:00:10 +0300 )edit



Edz ( 2019-03-20 09:50:34 +0300 )edit

2 Answers

Sort by » oldest newest most voted

answered 2019-03-19 19:55:47 +0300

pisarz1958 gravatar image

updated 2019-03-19 19:58:08 +0300

AFAIK JS support in Qt is fairly limited, here is relevant documentation. https://doc.qt.io/qt-5.6/qtqml-javascript-functionlist.html

The list in docs does not mention Promises, so I suppose they're simply not supported.

edit flag offensive delete publish link more



not 5.6 at least

coderus ( 2019-03-19 20:34:35 +0300 )edit

answered 2019-03-19 21:48:31 +0300

Kao gravatar image

There are several Javascript Promise implementations out there, see Promises A+.

However, such implementations typically hook into the Javascript scheduler, via setTimeout(). Since this is missing from the QtQml Javascript function list, you probably won't get any implementation to work that requires it. You may need to check the implementations for that, sounds tedious.

On the other hand, I notice there is a QML implementation mentioned in the implementations list, may be worth a look.

edit flag offensive delete publish link more


thank you, i did see that page, but assumed that there should be a native way without the need for.third party lib. ok i will check.it.out

pawel ( 2019-03-20 01:18:44 +0300 )edit

Question tools



Asked: 2019-03-19 16:26:42 +0300

Seen: 615 times

Last updated: Mar 20 '19