Skyper Posted January 4, 2019 Report Posted January 4, 2019 (edited) Hello, sorry for stupid post but I have question why after use this code second time console.log print the same information twice?3 turns on 3 times when I use in other place 'loggedOn' I see again console.log(this.informations) in other function. Someone can tell me why and what I can to do with that? Sorry for my rip English and code. { let p = new Promise((resolve,reject)=>{ this.steam.logOn(this.account_details); this.steam.on('loggedOn', () => { this.steam.setPersona(SteamUser.Steam.EPersonaState.Online); this.informations.steamID=this.steam.client.steamID; this.informations.accountid=this.steam.steamID.accountid; console.log(this.informations); this.steam.logOff(); setTimeout(()=>{ resolve(true); },1000); }); }); return p.then((resolve)=>{ console.log(`...`); }); } Console: Edited January 4, 2019 by Skyper Quote
Dr. McKay Posted January 4, 2019 Report Posted January 4, 2019 I would assume it's because this code is being called multiple times and is attaching a new listener to loggedOn every time. Quote
Skyper Posted January 4, 2019 Author Report Posted January 4, 2019 It's possible work on same lisener without multiple? Without promise I have normal console log without any double lines but I need promise... Thanks for respond @Dr. McKay! Quote
Dr. McKay Posted January 5, 2019 Report Posted January 5, 2019 Given that your steam-user seems to be temporary, you could just create a new one every time. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.