Activity
Overview
This module exports two composables that extend the core activity composable with map-specific capabilities.
useActivity(name, options)— sets up the activity store and automatically creates selection, probe, and highlight sub-stores.useCurrentActivity(options)— retrieves the current map activity context from anywhere in the component tree.
Usage
javascript
// In the activity component itself
import { useActivity } from '@kalisio/kdk/map.client'
const { selectItem, hasSelectedFeature, probeAtLocation } = useActivity('myMap', {
selection: true,
probe: true,
highlight: true
})
// In a child component
import { useCurrentActivity } from '@kalisio/kdk/map.client'
const { kActivity, hasSelectedFeature, getActivityProject } = useCurrentActivity()useActivity(name, options)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
name | string | — | Unique activity name within the application. |
options.selection | boolean | true | When true, also creates a selection store for this activity. |
options.probe | boolean | true | When true, also creates a probe store for this activity. |
options.highlight | boolean | true | When true, also creates a highlight store for this activity. |
Exposed
All values from the core useActivity are exposed, plus:
| Name | Type | Description |
|---|---|---|
setCurrentActivity(activity) | Function | Extended version that also propagates the activity to the selection, probe, and highlight composables. |
| (selection) | — | All values from useSelection(name) when options.selection is true. |
| (probe) | — | All values from useProbe(name) when options.probe is true. |
| (highlight) | — | All values from useHighlight(name) when options.highlight is true. |
useCurrentActivity(options)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
options.selection | boolean | true | When true, also retrieves the selection store from the current activity. |
options.probe | boolean | true | When true, also retrieves the probe store from the current activity. |
Exposed
All values from the core useCurrentActivity are exposed, plus:
| Name | Type | Description |
|---|---|---|
setActivityProject(project) | Function | Sets the project associated with the current activity (stored in a module-level shallowRef). |
getActivityProject() | Function | Returns the project currently associated with the activity. |
| (all from useActivity) | — | When an activity is active, all values exposed by its useActivity call (selection, probe, highlight) are merged in. |