Opensearch dashboards.icontextcontainer.registercontext
Home > opensearch-dashboards > IContextContainer > registerContext
IContextContainer.registerContext() method
Register a new context provider.
Signature:
registerContext<TContextName extends keyof HandlerContextType<THandler>>(pluginOpaqueId: PluginOpaqueId, contextName: TContextName, provider: IContextProvider<THandler, TContextName>): this;
Parameters
Parameter | Type | Description |
---|---|---|
pluginOpaqueId | PluginOpaqueId | The plugin opaque ID for the plugin that registers this context. |
contextName | TContextName | The key of the TContext object this provider supplies the value for. |
provider | IContextProvider<THandler, TContextName> | A IContextProvider to be called each time a new context is created. |
Returns:
this
The IContextContainer for method chaining.
Remarks
The value (or resolved Promise value) returned by the provider
function will be attached to the context object on the key specified by contextName
.
Throws an exception if more than one provider is registered for the same contextName
.