ChronoTrigger
  • ChronoTrigger
  • Setup
  • Time
  • Events
  • Timeline
  • Clock
Powered by GitBook
On this page
  • API
  • Methods
  • Accessors
  • Toggling between starting and stopping

Was this helpful?

Clock

PreviousTimeline

Last updated 4 years ago

Was this helpful?

ChronoTrigger::Clock is running the show around here.

Every 100ms () the Clock commands the scheduler to process any pending events.

API

Methods

start

Start (or un-pause) the Clock. Note that events with a before attribute that has already passed will be purged without being run.

stop

Pause the Clock.

Accessors

status

This will return :started or :stopped.

stopped?

This will return true or false, depending on whether the Clock is currently paused or not.

ticks

ticking?

The counterpart to stopped?, this will return true or false depending on whether the Clock is currently paused or not.

Toggling between starting and stopping

Here's a trick to flip the current status:

ChronoTrigger::Clock.send(ChronoTrigger::Clock.ticking? ? :stop : :start)

This will return an Integer representing the number of which have happened since the Clock was started.

configurable via initializer
ticks