Quick Promise - QML Promise Library


  • Qt Champions 2016

    Hi,

    In case you are looking for a Promise library that works well with QML , I would like to share my latest open source project with you. Its name is “Quick Promise”. It is a library that provides Promise object in QML way. It comes with a Promise component with signal and property. It could be resolved via a binary expression , another promise object, then trigger your callback by QueuedConnection.

    Moreover, it also provides Promise as Javascript object that don’t need to declare in QML way. The API is fully compliant with Promises/A+ specification (Passed all the test cases) and therefore it just works like many other Promise solutions for Javascript application.

    Example:

    
    Promise {
        resolveWhen: !someService.running // Once the expression become truth , the onFulfilled signal will be triggered via QueuedConnection
        onFulfilled: { 
        }
    }
    
    Promise {
        rejectWhen: timer.onTriggered  // Reject after timeout
       onRejected: {
       }
    }
    

    The project link: QuickPromise

    Enjoy it.


  • Lifetime Qt Champion

    Hi,

    You project reminds me of AngularJS. Looks pretty interesting ! Thanks for sharing


  • Qt Champions 2016

    @SGaist Thx

    haha, you also reminds me the time when I shift from AngularJS to QML. I tried to understand/write QML in an AngularJS way. Look for a solution of "Transclude" in QML. Assume the item in ListModel support 2 way data binding...


  • Qt Champions 2016

    v1.0.2 has been just released. Now user could resolve a promise by multiple signals and binary expression!

    Example

    1. Resolve by multiple signals.
    
    Promise {
        resolveWhen: Q.all([timer.triggered, loader.loaded]);
    }
    
    
    1. Resolve by signal and binary expression
    Promise {
        resolveWhen: Q.all([timer.triggered, promise2]);
    
        Promise {
            id : promise2
            resolveWhen: image.status === Image.Ready
        }
    }
    
    

  • Qt Champions 2016

    Quick Promise is now available at qpm.io . You could install latest version (1.0.2) via qpm install com.github.benlau.quickpromise


  • Qt Champions 2016

    v1.0.3 released.

    Changes

    1. The resolve parameter to promise generated by Q.all() become an array of results of original promises

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.