Update periodic_tasks example to ic-cdk-timers v1.0.0 API
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 613
- Forks
- 434
- Avg merge
- 8h 28m
- Merged PRs (30d)
- 9
Description
Problem
The rust/periodic_tasks/timer example uses ic-cdk-timers = "0.6" and the old closure-based API. The ic-cdk-timers v1.0.0 release (2025-11-13) introduced breaking changes to function signatures.
What needs updating
Dependencies (timer/Cargo.toml)
ic-cdk0.12→0.19ic-cdk-macros0.8→ currentic-cdk-timers0.6→1.0
Code (timer/src/lib.rs)
set_timer_interval signature changed — now takes FnMut() -> impl Future instead of FnOnce():
// Old (line 71):
let timer_id = ic_cdk_timers::set_timer_interval(secs, periodic_task);
// New:
let timer_id = ic_cdk_timers::set_timer_interval(secs, || async { periodic_task() });
ic_cdk::spawn() comment is obsolete (lines 75-77) — set_timer now takes futures directly, no spawn wrapper needed.
dfx references in doc comments (lines 53, 65, 82, 96) — dfx is deprecated, should use icp CLI.
Heartbeat example (heartbeat/Cargo.toml)
- Same outdated
ic-cdk/ic-cdk-macrosversions
Project-level
dfx.jsonat project root — should be migrated toicp.yaml
References
- ic-cdk-timers v1.0.0 changelog
- Found while updating developer-docs PR #9 (timers guide)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with rust/periodic_tasks/timer/Cargo.toml and src/lib.rs, then inspect heartbeat/Cargo.toml and the project-root dfx.json. Compare the timer code with the ic-cdk-timers v1.0.0 changelog and verify the documented API and CLI references. Done means both examples use the requested dependency versions and API, doc comments use icp, and the project configuration is migrated to icp.yaml.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend, build-system
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100