gpui-global

Manage app-wide global state in GPUI with the Global trait.

12.5k|757|Updated Jun 13, 2024
One-click install
npx skills add https://github.com/longbridge/gpui-component --skill gpui-global-longbridge
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gpui-global
Source: https://github.com/longbridge/gpui-component/tree/main/.claude/skills/gpui-global
Command: npx skills add https://github.com/longbridge/gpui-component --skill gpui-global-longbridge

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Global state management enables app-wide data to be shared across components and contexts, ensuring consistent configuration and resources without prop-drilling.

Core Features & Use Cases

  • Global trait: Implement on types to expose them globally and enable access from anywhere.
  • Set, update, and notify: Pattern for mutating global state with controlled reactivity and manual notifications when necessary.
  • Best practices: Arc-based sharing, immutability by default, and safe interior mutability for selective updates.
  • Use Cases: App configuration, feature flags, and shared services.

Quick Start

Define a global type by deriving Clone and implementing Global, then register it in the GPUI context and access or update it from components.

Frequently Asked Questions about gpui-global

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage global state in a Rust GPUI application without prop-drilling?

To manage global state, derive Clone on your type, implement the Global trait, and register it in the GPUI context. You can then access or update the data from anywhere in the application.

How does the Global trait work for sharing app-wide data in Rust?

It promotes safe, immutable defaults with interior mutability where needed, guiding best practices for Arc-based sharing and selective state updates across the application.

What is the best way to update shared application context in GPUI?

By default, it promotes immutability with safe interior mutability for selective updates, ensuring safe Arc-based sharing of app configuration and feature flags.

Can I use GPUI global state for app configuration and feature flags?

It ensures consistent configuration and shared resources without prop-drilling by leveraging Arc-based sharing and safe interior mutability.

When should I use interior mutability for global state management in Rust?

This approach ensures safe, Arc-based sharing of app-wide data while maintaining controlled reactivity through manual notify calls.