xibyte / jsketcher

Parametric 2D and 3D modeler written in pure javascript
http://web-cad.org
Other
1.49k stars 279 forks source link

throttle.js delay bug #120

Closed leannc closed 2 years ago

leannc commented 3 years ago

I read your code and found attach(observer) function in your throttle.js file a bit wrong. your code is : attach(observer) { let scheduled = false; let value = undefined; return this.stream.attach(val => { value = this.accumulator(val); if (!scheduled) { setTimeout(() => { scheduled = false; observer(value); }); } }, this.delay) }

And I think the "this.delay" may be in the wrong place since it is outside the setTimeout function. it is actually a parameter of attach function, but I searched for all files found that no attach function receives two paramters.

mmiscool commented 2 years ago

Looks like this should be solved by the commit by xibyte.