Tech Lead/Team Lead. Senior WebDev.
Intermediate Grade on Computer Systems-
High Grade on Web Application Development-
MBA (+Marketing+HHRR).
Studied a bit of law, economics and design
Location
Spain
Education
Higher Level Education Certificate on Web Application Development
Oh! nothing to do with classes it's just it receives an object but this is opinionated as I prefer to have the object structure for those "config" thingies, you can simply delete the brackets on the function declaration like that:
Nice snippet.
The new Promise callback should not be an async function. By passing an async fn to new Promise youβre βdouble promisingβ.
Refactoring to not depend on resolve/reject would solve that.
Or maybe
Tech Lead/Team Lead. Senior WebDev.
Intermediate Grade on Computer Systems-
High Grade on Web Application Development-
MBA (+Marketing+HHRR).
Studied a bit of law, economics and design
Location
Spain
Education
Higher Level Education Certificate on Web Application Development
Having it as async lets you handle the response, the error and any action to perform either it went OK or KO, so it can be customised specifically on it's environment.
Apologies, I didn't explain correctly.
Initially, I called the poll function incorrectly as follows:
The correct method (using your code) is:
Oh! nothing to do with classes it's just it receives an object but this is opinionated as I prefer to have the object structure for those "config" thingies, you can simply delete the brackets on the function declaration like that:
and we should be good π
Nice snippet.
The new Promise callback should not be an async function. By passing an async fn to new Promise youβre βdouble promisingβ.
Refactoring to not depend on resolve/reject would solve that.
Or maybe
Having it as async lets you handle the response, the error and any action to perform either it went OK or KO, so it can be customised specifically on it's environment.
instead handling it as generic inside the polling function.
But sure you can tweak it as you wish to fullfill your needs π