Promise QML Type
(DEPRECATED) Manages asynchronous operations. More...
Import Statement: | import ArcGIS.AppFramework.Promises 1.0 |
Properties
- _promise : object
- data : object
- isFulfilled : bool
- isRejected : bool
- isSettled : bool
- rejectWhen : object
- resolveWhen : object
Signals
Methods
- object _init()
- object _instanceOfSignal(object)
- object all(promises)
- object allSettled(promises)
- object instanceOfPromise(object)
- object reject(reason)
- object resolve(value)
- object setTimeout(callback, object interval)
- object then(onFulfilled, object onRejected)
Detailed Description
This component is in the process of being deprecated, and should not be used. Instead, use the JavaScript implementation for promises.
The Promise component manages asynchronous computation, allowing for separate processes to continue in parallel. This component must be instantiated before use. This should be used over the Promises component when reliability is more important than speed.
This code sample demonstrates usage of the Promise component. The promise is set to resolve when an image has loaded, and rejected if a timer elapses before the image has been loaded. In both cases, a corresponding message is logged to the console.
Item { ColumnLayout { anchors { fill: parent margins: 5 * AppFramework.displayScaleFactor } Image { id : image Layout.fillWidth: true //Layout.fillHeight: 50 * scaleFactor opacity: 0 fillMode: Image.PreserveAspectFit asynchronous: true source : "https://lh3.googleusercontent.com/_yimBU8uLUTqQQ9gl5vODqDufdZ_cJEiKnx6O6uNkX6K9lT63MReAWiEonkAVatiPxvWQu7GDs8=s640-h400-e365-rw"; } } Timer { id: timer running: true interval: 3000 } Promise { // Resolve when the image is ready resolveWhen: image.status === Image.Ready // Reject when time out. rejectWhen: timer.triggered onFulfilled: { console.log("Fulfilled - Image was ready first"); // If the timer is reached, the image will not be shown even it is ready. image.opacity = 1; } onRejected: { console.log("Rejected - Timer got there first"); } } }
Property Documentation
Returns true if the promise has been either fulfilled or rejected. Otherwise, returns false.
Signal Documentation
Method Documentation
If a promise currently does not exist, creates one with no currently set conditions or triggers.
Creates an object that contains the signal being watched for. This method informs the rejectWhen and resolveWhen methods.
The object parameter
The signal that was received.
Creates a promise object that will be fulfilled once a supplied array of input promises are fulfilled. If any input promise is rejected, this promise object will also be rejected.
The promises parameter
The promise object fulfilled after all supplied input promises.
Creates a promise object that will be fulfilled once a supplied array of input promises are fulfilled. If any input promise is rejected, the allSettled promise object will also be rejected. The state of allSettled will not change until all input promises are settled.
The promises parameter
The promise object fulfilled after all supplied input promises.
Returns the instance of the promise to be executed.
The object parameter
The promise to be executed.
If the defined reason is fulfilled, the promise is rejected, and the reason is passed to the rejected and settled signals.
The reason parameter
The criteria that the promise can be rejected for.
Resolves the promise, passing the given value to the fulfilled and settled signals.
The value parameter
The resolved value of the promise.
Sets a timer for the amount of milliseconds defined by the interval parameter, after which the provided callback function will be called.
The callback parameter
The function to execute when the timer completes.
The interval parameter
The amount of time to set the timeout operation to execute after, in milliseconds.
Defines an operation to execute when the promise is either fulfilled or rejected.
The onFulfilled parameter
Course of action if the promise operation is fulfilled.
The onRejected parameter
Course of action if the promise operation is rejected.