schema-components - v3.7.0
    Preparing search index...

    Interface ContextPort<T>

    Abstract provide / consume port that framework adapters implement against their native context primitive. The provide step wraps its children in the framework's provider machinery so any descendant calling consume receives the supplied value; consume is called from inside a child renderer to read the current value.

    The return type of provide and the argument type of consume are deliberately unknown so the port works for both React-style "wrap children in a provider component" implementations and Svelte-style "set on the current component instance" implementations without forcing one shape on the other.

    interface ContextPort<T> {
        provide(value: T, children: unknown): unknown;
        consume(): T;
    }

    Type Parameters

    • T

      The value carried by the context.

    Index

    Methods

    • Provide value to every descendant of children. The exact shape of children is framework-specific — ReactNode for React, the slot's render function for Svelte, the setup return value for Vue. The implementation simply makes the supplied value available to subsequent consume calls within that scope.

      Parameters

      • value: T
      • children: unknown

      Returns unknown

    • Read the currently provided value. The exact host primitive is framework-specific — useContext(ctx) in React, inject(key) in Vue, getContext(key) in Svelte. When no provider is mounted in scope, adapter implementations may return their canonical "default" value or undefined — the choice is adapter-defined.

      Returns T