Source code

Revision control

Copy as Markdown

Other Tools

[
{
"namespace": "alarms",
"permissions": ["alarms"],
"types": [
{
"id": "Alarm",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of this alarm."
},
"scheduledTime": {
"type": "number",
"description": "Time when the alarm is scheduled to fire, in milliseconds past the epoch."
},
"periodInMinutes": {
"type": "number",
"optional": true,
"description": "When present, signals that the alarm triggers periodically after so many minutes."
}
}
}
],
"functions": [
{
"name": "create",
"type": "function",
"description": "Creates an alarm. After the delay is expired, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm.",
"parameters": [
{
"type": "string",
"name": "name",
"optional": true,
"description": "Optional name to identify this alarm. Defaults to the empty string."
},
{
"type": "object",
"name": "alarmInfo",
"description": "Details about the alarm. The alarm first fires either at 'when' milliseconds past the epoch (if 'when' is provided), after 'delayInMinutes' minutes from the current time (if 'delayInMinutes' is provided instead), or after 'periodInMinutes' minutes from the current time (if only 'periodInMinutes' is provided). Users should never provide both 'when' and 'delayInMinutes'. If 'periodInMinutes' is provided, then the alarm recurs repeatedly after that many minutes.",
"properties": {
"when": {
"type": "number",
"optional": true,
"description": "Time when the alarm is scheduled to first fire, in milliseconds past the epoch."
},
"delayInMinutes": {
"type": "number",
"optional": true,
"description": "Number of minutes from the current time after which the alarm should first fire."
},
"periodInMinutes": {
"type": "number",
"optional": true,
"description": "Number of minutes after which the alarm should recur repeatedly."
}
}
}
]
},
{
"name": "get",
"type": "function",
"description": "Retrieves details about the specified alarm.",
"async": "callback",
"parameters": [
{
"type": "string",
"name": "name",
"optional": true,
"description": "The name of the alarm to get. Defaults to the empty string."
},
{
"type": "function",
"name": "callback",
"parameters": [
{
"name": "alarm",
"$ref": "Alarm",
"optional": true
}
]
}
]
},
{
"name": "getAll",
"type": "function",
"description": "Gets an array of all the alarms.",
"async": "callback",
"parameters": [
{
"type": "function",
"name": "callback",
"parameters": [
{
"name": "alarms",
"type": "array",
"items": { "$ref": "Alarm" }
}
]
}
]
},
{
"name": "clear",
"type": "function",
"description": "Clears the alarm with the given name.",
"async": "callback",
"parameters": [
{
"type": "string",
"name": "name",
"optional": true,
"description": "The name of the alarm to clear. Defaults to the empty string."
},
{
"type": "function",
"name": "callback",
"parameters": [
{
"name": "wasCleared",
"type": "boolean",
"description": "Whether an alarm of the given name was found to clear."
}
]
}
]
},
{
"name": "clearAll",
"type": "function",
"description": "Clears all alarms.",
"async": "callback",
"parameters": [
{
"type": "function",
"name": "callback",
"parameters": [
{
"name": "wasCleared",
"type": "boolean",
"description": "Whether any alarm was found to clear."
}
]
}
]
}
],
"events": [
{
"name": "onAlarm",
"type": "function",
"description": "Fired when an alarm has expired. Useful for transient background pages.",
"parameters": [
{
"name": "name",
"$ref": "Alarm",
"description": "The alarm that has expired."
}
]
}
]
}
]