-
• #2
Could it be that you're doing:
p.then((res)=>{ func_a(a); })
and not:
p.then((res)=>func_a(a))
The former will return 'undefined', which means the promise will execute immediately, but the latter returns the promise returned by func_a which should allow chaining
-
• #3
Thanks Gordon. It has been nearly 2 decades since I used js at all.
That is at least one step closer. Now it is executing the drawing function sequentially but it is doing it 5 times with the final value of "a".
It seems it is passing the reference of "a" in stead of the value of "a" to the promise function...
I forgot the mess javascripts references were in...
I completely forgot how to pass a variable to a promise without referencing to itself...
Am I forced to use an array and passing that to the promise function to resolve this or is there a better way to do this?
So far I have tried quite a few things but it seems all that is passed to the promise function is the final value of "a" -
• #4
:) You can create and execute a function for it...
let p = func_a(0); for (a=20;a<100;a=a+20) (function(a) { p=p.then((res)=>func_a(a)); })(a);
It's a bit crude, but it works
Hey there,
I'm having some issues with promise chaining and I am wondering if anyone can tell me what am doing wrong.
I have a function that returns a new promise and resolves when an interval function has been cleared.
Something like this:
now I have a for loop that is supposed to execute func_a sequentially but no matter how I try with promises it doesn't seem to work.
for example only draws the thing for the last value of a and
draws the first one perfectly followed by the last value of a.
What am I doing wrong?
I checked the references and I couldn't find an async option so I assume that is not a thing for the bangle?
Thanks in advance
ps. I am aware I can do:
I would just really prefer to do it in a for loop to save a lot of lines of code