Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions skills/gpui/references/async.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ impl MyView {
let _task = cx.spawn(async move |this, cx: &mut AsyncApp| {
// Task automatically cancelled when dropped
loop {
tokio::time::sleep(Duration::from_secs(1)).await;
cx.background_executor().timer(Duration::from_secs(1)).await;

this.update(cx, |state, cx| {
state.tick();
cx.notify();
Expand Down Expand Up @@ -145,7 +146,8 @@ cx.background_spawn(async move {
```rust
cx.spawn(async move |this, cx: &mut AsyncApp| {
loop {
tokio::time::sleep(Duration::from_secs(5)).await;
cx.background_executor().timer(Duration::from_secs(5)).await;

this.update(cx, |state, cx| {
state.tick();
cx.notify();
Expand Down
Loading