You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This block of code will log TIMER after 5 sec. But at first I thought that it logs TIMER after 15 (2 + 13) sec. because second timer.set(13000) call postpones timer. But in result this second call doesn't influence.
It will log TIMER1, but TIMER2 won't never be logged.
If I understood it correct setting timer is available only once until timer clearing.
Maybe timer has to throw an error in that case then.
And I think it would be great to clarify this cases in Readme.
What do you think?
The text was updated successfully, but these errors were encountered:
vitalets
changed the title
Some points to discuss
Calling timer.set() several times
Sep 17, 2018
Good catch!
I think the simplest solution is to automatically clear existing timer if .set is called again. So in both your examples nothing will be printed.
If you need to re-set timer on new timeout, you should provide new .then:
Hello!
I've found some unobvious behavior of
await-timeout
during its inclusion in our project. And want to discuss them with you and community.So the first my example is:
This block of code will log
TIMER
after 5 sec. But at first I thought that it logsTIMER
after 15 (2 + 13) sec. because secondtimer.set(13000)
call postpones timer. But in result this second call doesn't influence.Next example:
It will log
TIMER1
, butTIMER2
won't never be logged.If I understood it correct setting timer is available only once until timer clearing.
Maybe timer has to throw an error in that case then.
And I think it would be great to clarify this cases in Readme.
What do you think?
The text was updated successfully, but these errors were encountered: