Constructor options
Required? | Name | Type | Description |
---|---|---|---|
name | string |
Key to associate with this specific timer, use to disassociate multiple timers with the same scope | |
scope | string |
Determines the specificity of the timer, see DataService for available scopes | |
strategy | string / function |
strategy to use to resolve start time. Available strategies are 'first-user' (default) or 'last-user'. Can also take in a function to return a custom start time. | |
account | string |
The account id. In the Epicenter UI, this is the Team ID (for team projects) or User ID (for personal projects). Defaults to undefined. If left undefined, taken from the URL. | |
project | string |
The project id. Defaults to undefined. If left undefined, parsed from the URL. | |
token | string |
For projects that require authentication, pass in the user access token (defaults to undefined). If the user is already logged in to Epicenter, the user access token is already set in a cookie and automatically loaded from there. (See more background on access tokens). @see Authentication API Service for getting tokens. | |
transport | JQueryAjaxOptions | Options to pass on to the underlying transport layer. All jquery.ajax options are supported. | |
server | object |
||
server.host | string |
The value of host is usually the string api.forio.com , the URI of the Forio API server. This is automatically set, but you can pass it explicitly if desired. It is most commonly used for clarity when you are hosting an Epicenter project on your own server |
|
server.protocol | https / http | Defaults to https |
Methods
create(createOptions)
Creates a new Timer. Call start
to start ticking.
Parameters
Required? | Name | Type | Description |
---|---|---|---|
Yes | createOptions | object |
|
Yes | createOptions.timeLimit | number |
Limit for the timer, in milliseconds |
createOptions.startImmediately | boolean |
Determines if the timer should start ticking immediately. If set to false (default) call timer.start to start ticking. |
autoStart(options)
Get the current timer, or create a new one and immediately start it
Parameters
Required? | Name | Type | Description |
---|---|---|---|
Yes | options | object |
|
Yes | options.timeLimit | number |
Limit for the timer, in milliseconds |
cancel()
Cancels current timer. Need to call create
again to restart.
Parameters
None
addTimerAction(action)
Adds a custom action to the timer state. Only relevant if you're implementing a custom strategy.
Parameters
Required? | Name | Type | Description |
---|---|---|---|
Yes | action | string |
start()
Start the timer
Parameters
None
pause()
Pause the timer
Parameters
None
resume()
Resumes a paused timer
Parameters
None
getCurrentTime()
Helper method to return current server time
Parameters
None
getState()
Resumes current state of the timer, including time elapsed and remaining
Parameters
None
getChannel()
Resumes a channel to hook into for timer notifications.
Parameters
None