Interface IComponentFramework

The component framework allows TypeScript components to communicate using well-defined APIs.

APIs are TypeScript interfaces that meet certain requirements:

  • It implements IComponentApi and has a unique IComponentApi._apiId property,
  • It only contains methods that return Promises, of which both the parameters and the return type are serializable values,
  • It can raise events, of which the event args are serializable.
interface IComponentFramework {
    getApi<TApi>(apiId: TApi["_apiId"]): TApi;
    registerApi<TApi>(apiId: TApi["_apiId"], componentApi: TApi): void;
}

Methods

  • Obtain an implementation of the API with the specified API ID.

    The implementation can either be a "local" object (same web context), or a facade for a remote object (different web context).

    The component framework ensures that method calls and events are propagated to remote objects.

    Type Parameters

    Parameters

    • apiId: TApi["_apiId"]

      The unique identifier of the API.

    Returns TApi

  • Register an API with the component framework. This allows other components to consume this API.

    If this is the singleton host, other remote component frameworks will be able to remotely call this API.

    Type Parameters

    Parameters

    • apiId: TApi["_apiId"]

      The unique identifier of the API.

    • componentApi: TApi

      An object implementing the API.

    Returns void