Is there any penalty to using a lot of chained promises together #1681
Replies: 3 comments
-
Posted at 2023-11-17 by @gfwilliams What you're doing there seems really nice and clean. The downside is that when it first starts, it's using a bit of memory to store all the promises all at once, but it's not really that bad. If you nested everything with callbacks you'd avoid that up-front memory usage, but then it ends up re-parsing all the functions inside each time it goes through an iteration, so there are downsides there too (in addition to it looking awful). Only other thing I might mention is if you're just doing:
over and over, you could create an array, like:
but I wonder if that's really better - i'd stick with what you have for now |
Beta Was this translation helpful? Give feedback.
-
Posted at 2023-11-17 by user156811 Thanks again for the great help |
Beta Was this translation helpful? Give feedback.
-
Posted at 2023-12-05 by @allObjects @user156811, before promises, I did non-blocking sequencing in a different way - see: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2023-11-17 by user156811
Basically i have some code that will send a command out and then wait for the busy flag pin pulled high. To link these things together i just have a bunch of promises that chain together. Is that bad practice. As in will it be bad for performance to do something like this.
Example of what i mean
https://gist.github.com/brendena/fddc11a1660eb5d1f03a17466b314e66#file-gistfile1-txt-L97
Beta Was this translation helpful? Give feedback.
All reactions