Refactor promise/callbacks to async/await
starakaj opened this issue · comments
Given the relatively lower complexity, @fde31 and I felt like we should use async/await for asynchronous execution wherever possible. Otherwise we kinda have to keep dealing bugs/confusion related to older promise syntax. Current offenders include at least the dog.ceo example, but there maybe others.
Maybe I've been writing in JavaScript for too long, but would it make sense to use just straight up callbacks? Am I just so used to callbacks that I can't see that await/async is easier?
well. The max-api does not support callback syntax and always returns promises.. hmm
got it! i agree then, async/await is more straightforward.
would it ever make sense to ever support callback syntax for max-api? should old javascript syntax just die?
Thoughts:
- We want to make it clear that N4M lets you do modern javascript stuff. Having async/await in the examples is a great way to enforce that.
- We want a standard (I think) rather than mixing between the three options in the code. Do we want to use callbacks everywhere?
- Callbacks are annoying.
closing out as this is something for Cycling74/n4m-core-examples