Skip to content

context

wybthon.context

Tiny context system for passing values through the component tree.

Context dataclass

Opaque context identifier and default value container.

Provider

Bases: Component if Component is not None else object

Context provider component.

Props
  • context: Context
  • value: Any
  • children: VNode or list of VNodes

render()

Render passthrough children; VDOM manages push/pop of context value.

create_context(default)

Create a new Context with a unique identifier and default value.

pop_provider_value()

Pop the latest provider scope from the context stack if present.

push_provider_value(ctx, value)

Push a new provider value for ctx onto the context stack.

use_context(ctx)

Read the current value for ctx, or its default if not provided.