Use JavaScript Promises from QML
-
The latest release of V-Play 2.18.1 includes JavaScript Promises for usage in QML.
Here is an example of how to use promises, together with the new HttpRequest type, based on DuperAgent:
import VPlayApps 1.0 import QtQuick 2.0 App { Component.onCompleted: { var p1 = Promise.resolve(3); var p2 = 1337; var p3 = HttpRequest .get("http://httpbin.org/get") .then(function(resp) { return resp.body; }); var p4 = Promise.all([p1, p2, p3]); p4.then(function(values) { console.log(values[0]); // 3 console.log(values[1]); // 1337 console.log(values[2]); // resp.body }); } }
There are a lot more new features that you can check out in the full blog post: https://v-play.net/updates/release-2-18-1-javascript-promises-for-rest-services-tinder-swipe-material-cards-qml-qsortfilterproxymodel-qml-youtube-player