atomico-context

Create and consume cross-shadow-DOM contexts for Atomico web components.

1.3k|44|Updated Aug 25, 2018
One-click install
npx skills add https://github.com/atomicojs/atomico --skill atomico-context
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: atomico-context
Source: https://github.com/atomicojs/atomico/tree/main/.agents/skills/atomico-context
Command: npx skills add https://github.com/atomicojs/atomico --skill atomico-context

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Atomico's context system solves the problem of sharing state or dependencies across nested web components without prop-drilling, especially across shadow DOM boundaries, by providing a purpose-built, event-based context API.

Core Features & Use Cases

  • createContext: Define a context with a default value and register it as a custom element to provide values to descendants.
  • useContext: Consume the current value from the nearest provider, enabling reactive components to respond to changes.
  • useProvider: Provide a value for a context to all descendants, supporting dynamic updates and overrides through nesting.
  • Nested contexts and value overrides across different tree levels enable scoped configuration for complex component trees.
  • Cross-shadow DOM communication uses events to traverse boundaries safely.

Quick Start

Define a context with createContext, wrap your components with a provider, and consume the value with useContext.

Frequently Asked Questions about atomico-context

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

FAQPage Schema
How do I share state across web components without prop-drilling?▼

To share state across web components without prop-drilling, use an event-based context system. This Skill provides createContext and useContext APIs to pass values directly to nested descendants.

Can context be shared across shadow DOM boundaries in Atomico?▼

Yes, context can be shared across shadow DOM boundaries in Atomico. The system uses event-based communication to safely traverse nested shadow DOMs and deliver state to deeply nested components.

What is the best way to override context values in a nested component tree?▼

The best way to override context values in a nested component tree is using nested providers. The useProvider hook supports dynamic updates and scoped overrides at different tree levels for scoped configuration.

How do I create and consume a context provider for web components?▼

To create and consume a context provider for web components, define a context with createContext, wrap components with a provider, and consume the value using the useContext hook for reactive updates.

Does Atomico context support reactive updates when provider values change?▼

Yes, Atomico context supports reactive updates when provider values change. The useContext hook retrieves the current value from the nearest provider, enabling reactive components to automatically respond to dynamic state changes.