跳至内容

useImageryLayerScope

将“ImageryLayerCollection”操作的副作用范围化,并在卸载时自动删除

Usage

ts
TODO;

Type Definitions

typescript
import type { ImageryLayer, ImageryLayerCollection } from 'cesium';
import type { MaybeRefOrGetter, ShallowReactive } from 'vue';
import type { EffcetRemovePredicate } from '../useCollectionScope';
export interface UseImageryLayerScopeOptions {
    /**
     * The collection of ImageryLayer to be added
     * @default useViewer().value.imageryLayers
     */
    collection?: MaybeRefOrGetter<ImageryLayerCollection>;
    /**
     * The second parameter passed to the `remove` function
     *
     * `imageryLayers.remove(imageryLayer,destroyOnRemove)`
     */
    destroyOnRemove?: boolean;
}
export interface UseImageryLayerScopeRetrun {
    /**
     * A `Set` for storing SideEffect instance,
     * which is encapsulated using `ShallowReactive` to provide Vue's reactive functionality
     */
    scope: Readonly<ShallowReactive<Set<ImageryLayer>>>;
    /**
     * Add SideEffect instance
     */
    add: <T extends ImageryLayer>(imageryLayer: T) => T;
    /**
     * Remove specified SideEffect instance
     */
    remove: (imageryLayer: ImageryLayer, destroy?: boolean) => boolean;
    /**
     * Remove all SideEffect instance that meets the specified criteria
     */
    removeWhere: (predicate: EffcetRemovePredicate<ImageryLayer>, destroy?: boolean) => void;
    /**
     * Remove all SideEffect instance within current scope
     */
    removeScope: (destroy?: boolean) => void;
}
/**
 * Make `add` and `remove` operations of `ImageryLayerCollection` scoped,
 * automatically remove `ImageryLayer` instance when component is unmounted.
 */
export declare function useImageryLayerScope(options?: UseImageryLayerScopeOptions): UseImageryLayerScopeRetrun;