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
The stopped() method returns the information whether the timeout is still running or not, and it does not check for expiration. The expired() method checks for expiration, and also stops the timer, so it only returns true a single time. In a table:
Situation
stopped()
expired()
Stopped
true
false
Started, not expired yet
false
false
Started, expired
before expired() is called: false after expired() is called: true
true, but only once false on second and all following calls
The current implementation is good for use cases where some code needs to be run a single time after a timeout expires. However, it's not ideal for use cases where one actually needs "delay" semantics, i.e. do nothing while the timeout is running, but always run the code after expiration.
It's not clear at the moment what the best solution is. Ideas:
Change semantics of the expired() method to return true when the Timeout is stopped. Need to check all existing usages whether this is possible, and also whether it makes sense.
Add a method stoppedOrExpired(), which at least shows up in IntelliSense and should make developers think.
Add another class Delay that actually implements delay semantics. Could use Timeout internally.
The text was updated successfully, but these errors were encountered:
The
stopped()
method returns the information whether the timeout is still running or not, and it does not check for expiration. Theexpired()
method checks for expiration, and also stops the timer, so it only returnstrue
a single time. In a table:after expired() is called: true
false on second and all following calls
The current implementation is good for use cases where some code needs to be run a single time after a timeout expires. However, it's not ideal for use cases where one actually needs "delay" semantics, i.e. do nothing while the timeout is running, but always run the code after expiration.
It's not clear at the moment what the best solution is. Ideas:
expired()
method to return true when the Timeout is stopped. Need to check all existing usages whether this is possible, and also whether it makes sense.stoppedOrExpired()
, which at least shows up in IntelliSense and should make developers think.Delay
that actually implements delay semantics. Could useTimeout
internally.The text was updated successfully, but these errors were encountered: