Skip to content

Commit

Permalink
doc: add notes that timer jobs should be side-effect-free
Browse files Browse the repository at this point in the history
  • Loading branch information
ggreif committed Jan 17, 2025
1 parent 87f65ab commit 3a26e5b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Timer.mo
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ module {
/// Installs a one-off timer that upon expiration after given duration `d`
/// executes the future `job()`.
///
/// Note: Since `job` can be called more than once (under rare circumstances),
/// it should not possess side-effects.
///
/// ```motoko no-repl
/// let now = Time.now();
/// let thirtyMinutes = 1_000_000_000 * 60 * 30;
Expand All @@ -37,6 +40,8 @@ module {
/// executes the future `job()` and reinserts itself for another expiration.
///
/// Note: A duration of 0 will only expire once.
/// Note: Since `job` can be called more than once (under rare circumstances),
/// it should not possess side-effects.
///
/// ```motoko no-repl
/// func checkAndWaterPlants() : async () {
Expand Down

0 comments on commit 3a26e5b

Please sign in to comment.