This module provides functionality of counting some events which happened in user-determined certain time range. You can stop and restart the time-induced change as you like. Useful for scorering typing-practice game etc.
create a RecentEventCounter from some configuration. Recode is used in order to prevent user from misunderstanding the time unit.
Call this when the observed event happend.
rec : RecentEventCounter
rec = create { durationInMillis = 30000, isMoving = False}
rec
|> increment
|> count
--> 1Make subscription for the time-induced change of RecentEventCounter. If the timer is moving, the passed milliseconds is enlarged each frame. Otherwise nothing changes. If the oldest event memorized expires its lifetime then the event is forgotton and the event count decreases by one.
subscribe toMsg recMake the timer stops whichever it has been originally moving or not.
Make the timer moves whichever it has been originally moving or not.
If the timer is moving, then stops it. Else, restart the timer.
Return RecentEventCounter with the event count forgotten,
while the passed time from initialization of the application is remained.
Return RecentEventCounter in completely seme state as it was created.
Return how many times increment is called during the user-defined length of time by now.
Returns if the timer is currently moving.
Returns time in milliseconds passed with the timer moving.
An opaque type representating a counter for events having recently happend.