gpui-async
CommunityCoordinate UI and background tasks in GPUI.
System Documentation
What problem does it solve?
gpui-async coordinates foreground UI updates with long-running background tasks in GPUI apps.
Core Features & Use Cases
- Foreground tasks: schedule UI updates using cx.spawn, ensuring updates occur on the UI thread.
- Background tasks: offload CPU-heavy work with cx.background_spawn and chain results back to the UI via then.
- Task lifecycle: automatic cancellation on drop and safe cleanup to prevent leaks.
- Periodic tasks and coordination: support recurring work and synchronization between foreground and background work.
Quick Start
Foreground Task example: impl MyComponent { fn fetch_data(&mut self, cx: &mut Context<Self>) { let entity = cx.entity().downgrade(); cx.spawn(async move |cx| { // Runs on UI thread, can await and update entities let data = fetch_from_api().await; entity.update(cx, |state, cx| { state.data = Some(data); cx.notify(); }).ok(); }).detach(); } }
Background Task example: impl MyComponent { fn process_file(&mut self, cx: &mut Context<Self>) { let entity = cx.entity().downgrade(); cx.background_spawn(async move { let result = heavy_computation().await; result }).then(cx.spawn(move |result, cx| { entity.update(cx, |state, cx| { state.result = result; cx.notify(); }).ok(); })).detach(); } }
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: gpui-async Download link: https://github.com/zerx-lab/rmx/archive/main.zip#gpui-async Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.