Skip to content

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

ParameterTypeDefaultDescription
namestringUnique activity name within the application.
options.selectionbooleantrueWhen true, also creates a selection store for this activity.
options.probebooleantrueWhen true, also creates a probe store for this activity.
options.highlightbooleantrueWhen true, also creates a highlight store for this activity.

Exposed

All values from the core useActivity are exposed, plus:

NameTypeDescription
setCurrentActivity(activity)FunctionExtended 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

ParameterTypeDefaultDescription
options.selectionbooleantrueWhen true, also retrieves the selection store from the current activity.
options.probebooleantrueWhen true, also retrieves the probe store from the current activity.

Exposed

All values from the core useCurrentActivity are exposed, plus:

NameTypeDescription
setActivityProject(project)FunctionSets the project associated with the current activity (stored in a module-level shallowRef).
getActivityProject()FunctionReturns 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.