Skip to content

@deltares/fews-web-oc-composables


@deltares/fews-web-oc-composables / usePiTimeSeries

Function: usePiTimeSeries() ​

usePiTimeSeries(options): UsePiTimeSeriesReturn

Defined in: usePiTimeSeries/index.ts:246

Beta

Fetches a set of FEWS PI time series and keeps them up to date via a useRefreshCoordinator.

Identical requests that are in flight at the same time, also from other component instances, result in a single webservice request.

Parameters ​

options ​

UsePiTimeSeriesOptions

MemberTypeDescription
enabled?Ref<boolean, boolean>Controls whether time series may be fetched.
query?MaybeRefOrGetter<PiTimeSeriesQueryOptions | undefined>Query options applied to every request.
refresh?{ immediate?: boolean; intervalMs?: number; policies?: RefreshPolicy[]; systemTick?: Ref<Date | undefined, Date | undefined> }Configuration for automatic time series refreshing.
requestsMaybeRefOrGetter<PiTimeSeriesRequest[] | undefined>The time series requests, identified by a unique key. When undefined or empty, in-flight requests are cancelled and no new requests are made.
webservice?PiWebserviceOptionsOptional webservice configuration for standalone usage. When omitted, the host-provided webservice context is used.

Configuration for the requests and automatic refreshing. See UsePiTimeSeriesOptions.

Returns ​

UsePiTimeSeriesReturn

MemberTypeDescription
cancel() => voidCancels the running requests of this instance.
entriesReadonly<ShallowRef<Record<string, PiTimeSeriesEntry>>>The state per request key.
errorsComputedRef<Record<string, Error>>The errors per request key.
fetch() => Promise<void>Fetches all time series immediately.
lastRefreshAtReadonly<Ref<Date | undefined>>The time at which the most recent refresh completed.
lastTriggerPolicyReadonly<Ref<RefreshPolicy | undefined>>The policy that caused the most recent refresh.
loadingComputedRef<boolean>Whether any request is loading without a previous response.
loadingKeysComputedRef<string[]>The keys of the requests that are in progress.
pauseRefresh() => voidPauses automatic refreshes.
refreshingComputedRef<boolean>Whether any request is refreshing a previous response.
requestRefresh() => voidRequests a refresh through the refresh coordinator.
responsesComputedRef<Record<string, TimeSeriesResponse>>The available responses per request key.
resumeRefresh() => voidResumes automatic refreshes after they have been paused.

Reactive responses and state per request key, and controls for fetching and refreshing. See UsePiTimeSeriesReturn.

Example ​

ts
import { computed } from 'vue'
import { usePiTimeSeries } from '@deltares/fews-web-oc-composables'

const requests = computed(() =>
  actionRequests.value.map((r) => ({ key: r.key, relativeUrl: r.request })),
)

const { responses, loading } = usePiTimeSeries({
  requests,
  query: () => ({ startTime: start.value, endTime: end.value }),
})