[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vr / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / asp / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / qst / sci / soc / sp / tg / toy / trv / tv / vp / wsg / wsr / x] [Settings] [Search] [Home]
Settings Home
/wsr/ - Worksafe Requests

Thread archived.
You cannot reply anymore.

File: fffffffffffff.png (125 KB, 1042x1500)
125 KB
125 KB PNG
So, I have two buttons, if I press first one it'll start endless cycle, if I press second one - it should break it.
Sound easy, but I encountered one problem which I have no idea how to solve.
I searched internet for this and I found that the problem is in flow, and I need multi-flows to solve this, and it easily can be done in c++ or c#. But js can have only one flow, and this option is not avaible for me.

I just want to know, is there any way to break cycles from outside in js?
You've made a few mistakes.
First off I'm not sure your function is reachable and I can't test right now but just to be sure you should declare it as
>var myFunc = function() { ... }
Second mistake and probably the reason your script isn't working is that the syntax foo() calls foo immediately. If you want to pass foo as an argument to another function (aka a callback) you must write something like
>window.setTimeout(foo, 4000)
Again I can't test right now but that should help you
>var myFunc
Uhm. Why? What for? Tried it, script breaks.
>window.setTimeout(foo, 4000)
Added window. before setimeout, but nothing has changed.
Read more carefully.

settimeout(myfunc,4000)//call myfunc() in 4000
settineout(myfunc(),4000)//call myfunc() right now, then the function it returns in 4000
this works for me- theres a pause at the start though...
It does work, but you need to press the button right before the next iteration starts.
But I guess I am niggling.
I knew there was a simplier solution, than messing with flows. Thanks anon, I'll think how to imrove it more.

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.