|
May wanna think about that design man. In years and years of JavaScript I've never had to nest or chain timers like that... ever. Promises or events yeah, but not timers.
Jeremy Falcon
|
|
|
|
|
Promises are the way to go.
Something like this:
function wait(timeout) {
return new Promise(function(resolve) {
setTimeout(resolve, timeout);
});
}
function waitFor(timeout){
return function(result){
return new Promise(function(resolve){
setTimeout(function(){ resolve(result); }, timeout);
});
};
}
Usage:
wait(2000)
.then(function() {
alert("Thinking...");
return 42;
})
.then(waitFor(1000))
.then(function(result) {
alert("The answer is " + result)
});
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm the one that up-voted this, but I would like to add a suggestion. If his intent is to do simple animation with this, he's much better off using CSS3 animation with keyframes.
Jeremy Falcon
|
|
|
|
|
Thanks, Jeremy. I do plan to do basic animations, like a e.g. rapid fade-in of card as it is flashed on and fade-out when it gets "turned face down" again, but my main concern with timers is game logic. A visibly reducing wait until the next card is shown, then a very short wait while the card is shown, etc. Also the time the player has to choose an answer must be limited, quickest answers tracked, all that spade work.
"'Do what thou wilt...' is to bid Stars to shine, Vines to bear grapes, Water to seek its level; man is the only being in Nature that has striven to set himself at odds with himself."
—Aleister Crowley
|
|
|
|
|
Sounds cool man. I hope it comes out awesome.
Jeremy Falcon
|
|
|
|
|
Also, if your intent is simple animation, delay the showing of a card, etc. you can use CSS3 to pull that off with much less hassle.
Jeremy Falcon
|
|
|
|
|
Near top of the list for iteration 2.
"'Do what thou wilt...' is to bid Stars to shine, Vines to bear grapes, Water to seek its level; man is the only being in Nature that has striven to set himself at odds with himself."
—Aleister Crowley
|
|
|
|
|
Reckon I better go to bed. Hungover before I sleep. Birthday finished.
Michael Martin
Australia
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible."
- Mr.Prakash One Fine Saturday. 24/04/2004
|
|
|
|
|
|
Slacker007 wrote: How's the diabetes?
It was going very well and the doctor was well pleased, but I was wasting away eating the cardboard and water. Down to 82kg at 188cm, like an anorexic AIDS victim. Been eating and drinking everything for the past few months but no lollies, chocolates, ice cream etc. Will have to go back to being good for a while though I'd like to find a middle ground. I can't just eat 3 meals a day, my metabolism is still to good for that but having to wait 2 hours for a blood check seems to dictate that's all you can do.
Michael Martin
Australia
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible."
- Mr.Prakash One Fine Saturday. 24/04/2004
|
|
|
|
|
Has Anyone Seen Mike Hunt wrote: though I'd like to find a middle ground. I can't just eat 3 meals a day, my metabolism is still to good for that
My situation as well. Very frustrating.
|
|
|
|
|
Is lip service just regular Botox injections?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Does detox reverse the process?
... such stuff as dreams are made on
|
|
|
|
|
do deaf people botox their hands?
Installing Signature...
Do not switch off your computer.
|
|
|
|
|
Go to one of those places that provides rentals if the service is going to take longer
Installing Signature...
Do not switch off your computer.
|
|
|
|
|
Is that why you have a stiff upper lip?
|
|
|
|
|
That's a swell quip, although it bags the question as to whether, as it passes through the syringe needle, if its called aflotoxin or just an injection.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
No - lip service is what girlfriends will do until they have a wedding ring.
I'm pretty sure I would not like to live in a world in which I would never be offended.
I am absolutely certain I don't want to live in a world in which you would never be offended.
Freedom doesn't mean the absence of things you don't like.
Dave
|
|
|
|
|
DRHuff wrote: No - lip service is what girlfriends will do demand until they have a wedding ring. FIFY
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
I concede - I know when I'm licked.
I'm pretty sure I would not like to live in a world in which I would never be offended.
I am absolutely certain I don't want to live in a world in which you would never be offended.
Freedom doesn't mean the absence of things you don't like.
Dave
|
|
|
|
|
|
Nice!
|
|
|
|
|
Why don't I ever get visited by this magical Win10 fairy? I've been using Win10 on multiple machines since it was released and have never had a serious issue*. I feel so left out.
The worst I have had is my PC updated and rebooted overnight. When I relaunched my browser it did not reopen my last tabs. I was devastated but after much counseling, I recovered.
*knock on wood
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
It only happens to people using their machine for work,
like people that drive 4WD's and never get off the tarmac - they never break their axle's etc.
Installing Signature...
Do not switch off your computer.
|
|
|
|
|
Hey, Solitaire is hard work man!
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|