For every function in the framework which uses an asynchronous callback, there are two versions: one which issues a Promise, and one which takes a more traditional callback function. For example, the code to display a dialog to select an instrument can be written in either of the following ways:
// Traditional version
Framework.SelectInstrument(function(instrumentId) {
// Called asynchronously by the framework when the user selects a market, or cancels
});
// Version using Promise (and optional arrow function)
Framework.pSelectInstrument().then( (instrumentId) => {
// Called asynchronously by the framework when the user selects a market, or cancels
});
The framework uses a simple naming convention where the "standard" version of the function is something like
Promises in the framework always settle by fulfilling, never by rejecting. For example, a trading request settles by fulfilling regardless of whether it succeeded or failed, with a parameter describing the success or failure result.
There can be subtle differences between the standard and Promise versions of functions. For example - as described in the previous section -