Skip to content

Commit 8658009

Browse files
committed
Adding alarmInfo example.
1 parent 2991a1c commit 8658009

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/content/docs/durable-objects/api/alarms.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ export class AlarmExample extends DurableObject {
106106
}
107107
```
108108

109+
The following example shows how the `alarmInfo` property can be leveraged to identify if the alarm event has been attempted before.
110+
111+
```js
112+
class MyDurableObject extends DurableObject {
113+
async alarm(alarmInfo) {
114+
if (alarmInfo?.retryCount != 0) {
115+
console.log("This alarm event has been attempted ${alarmInfo?.retryCount} times before.");
116+
}
117+
}
118+
}
119+
```
120+
109121
## Related resources
110122
111123
- Understand how to [use the Alarms API](/durable-objects/examples/alarms-api/) in an end-to-end example.

0 commit comments

Comments
 (0)