Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Announcements
  4. Use JavaScript Promises from QML
Qt 6.11 is out! See what's new in the release blog

Use JavaScript Promises from QML

Scheduled Pinned Locked Moved Announcements
1 Posts 1 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    h00bs
    wrote on last edited by
    #1

    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

    Developer at Felgo - https://felgo.com/qt

    Develop mobile Apps for iOS & Android with Qt
    Develop Games with Qt

    Felgo is an official Qt Technology Partner

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved