PluginContext
Plugin components and callbacks receive the base Context plus the plugin-specific properties documented below.
PluginContext is received by:
- InitComponent - as props
- API methods - as the first argument
- Panel render components - as props
- Control render components - as props
- Button callbacks (
onClick,enableWhen,hiddenWhen,excludeWhen,pressedWhen) - as an argument (onClickreceives event first, context second)
Base Context Properties
See Context for the following properties available to all contexts:
appConfig- Application configurationappState- Current application stateiconRegistry- Icon registrymapProvider- Map provider instancemapState- Current map stateservices- Core services
Plugin-Specific Properties
pluginConfig
Type: Object
Plugin-specific configuration. Contains all properties from the PluginDescriptor except id and load.
When using the factory function pattern, any options passed to the factory become available here:
// When registering:createScaleBarPlugin({ units: 'imperial' })
// Within the plugin:const { units } = context.pluginConfigSee Creating a Plugin Descriptor for the full pattern.
pluginState
Type: Object
Plugin-specific state managed by the plugin's reducer, plus utilities for updating state.
{ // State values from your reducer's initialState isActive: false,
// Dispatch function for updating plugin state dispatch: ({ type, payload }) => { /* ... */ }}// Access stateconst { isActive } = context.pluginState
// Update statecontext.pluginState.dispatch({ type: 'setActive', payload: true })