UNPKG

vue3-openlayers

Version:
19 lines (17 loc) 1.19 kB
import { Ref, ShallowRef } from 'vue'; import { Cluster, Source } from 'ol/source'; import { Layer } from 'ol/layer'; import { Feature } from 'ol'; import { IfAny } from '@vue/shared'; /** * Create a Source and watch for source, prop and layer changes * @param SourceClass The Class of the source which should be created * @param layer A `ref` carrying the parent components layer the layer should be applied to * @param props The properties which should be passed to the SourceClass * @param eventsToHandle The event names list for events that should be passed from the source through the component */ export default function useSource<T extends Source>(SourceClass: new (...args: any[]) => T, layer: Ref<Layer> | Ref<Cluster<Feature>> | null | undefined, props: ConstructorParameters<typeof SourceClass>[0], eventsToHandle?: string[], sourceUpdateActions?: (source: T) => void): { source: Ref<any, any> extends T ? T extends T & Ref<any, any> ? IfAny<T, ShallowRef<T>, T> : ShallowRef<T> : ShallowRef<T>; updateSource: () => Ref<any, any> extends T ? T extends T & Ref<any, any> ? IfAny<T, ShallowRef<T>, T> : ShallowRef<T> : ShallowRef<T>; removeSource: () => void; };