Skip to content

Instantly share code, notes, and snippets.

@DevLucem
Created March 10, 2022 07:01
Show Gist options
  • Save DevLucem/95e846c16227880859769ce94d9ea728 to your computer and use it in GitHub Desktop.
Save DevLucem/95e846c16227880859769ce94d9ea728 to your computer and use it in GitHub Desktop.
TradingView To Anywhere Platform Creation Format
class Platform {
// receive and validate the data
constructor(data) {
this.command = {valid: true};
if (typeof data === 'string') this.command.data = data
else if (typeof data === 'object') {
} else this.command.valid = false;
}
// execute the activation automation process
process(activations = [{}]){
return new Promise( (resolve, reject) => {
if (!this.command.valid) return reject();
let results = {}; activations.forEach( activation => {
doAutomationAction().then( res => results[activation.id] = res)
.catch(error => results[activation.id] = error)
.finally(()=> {if (Object.keys(results).length>=activations.length) resolve(results)})
})
})
}
}
module.exports = Telegram
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment