Last active
March 31, 2020 22:40
-
-
Save orlybg/e77f2b693657cd5297b5e4a9e0eb830e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement, track} from 'lwc'; | |
// importing apex class to make callout | |
import getSomething from '@salesforce/apex/MyAPIstuff.retrieve'; | |
import startRequest from '@salesforce/apexContinuation/MyAPIstuff.startRequest'; | |
export default class MyAPIstuff extends LightningElement { | |
@track token; | |
@track imperativeContinuation = {}; | |
// Imperative Call | |
callContinuation() { | |
startRequest() | |
.then(result => { | |
this.imperativeContinuation = result; | |
}) | |
.catch(error => { | |
this.imperativeContinuation = error; | |
} | |
); | |
} | |
get formattedImperativeResult() { | |
//result = JSON.stringify(this.imperativeContinuation); | |
//console.log('formattedImperativeResult', result); | |
return JSON.stringify(this.imperativeContinuation); | |
} | |
handleConnection() { | |
alert('Working...'); | |
var t0 = performance.now(); | |
getSomething() | |
.then(data => { | |
this.promiseFunc(data); | |
}) | |
.catch(error => { | |
alert('EXCEPTION!!!'); | |
console.log('error ====> ', error); | |
}) | |
} | |
promiseFunc(data) { | |
console.log('promiseFunc', data); | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log('resolving...'); | |
var t1 = performance.now(); | |
// console.log("Call to doSomething took " + (t1 - t0) + " milliseconds."); | |
console.log('DONE'); | |
console.log('The Data: ', JSON.parse(data)); | |
//this poiint; | |
data.result.forEach(function(elem){ | |
console.log(elem.name) | |
}); | |
resolve(data); | |
}, 20000); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment