This document provides a technical reference for the core internal services of WorldWideView. These services are designed to be used by plugins and core components for communication and data management.
The DataBus is a central event emitter used for decoupled, typed communication between different parts of the application.
- Import:
import { dataBus } from "@/core/data/DataBus"; - Source:
src/core/data/DataBus.ts
Subscribes to an event. Returns an unsubscribe function.
- event: The event name (keys of
DataBusEvents). - handler: A callback function receiving the event data.
Unsubscribes from an event.
- event: The event name.
- handler: The handler function to remove.
Broadcasts an event to all subscribers.
- event: The event name.
- data: The payload for the event.
Removes all listeners for a specific event, or all listeners if no event is provided.
The PluginRegistry manages the registration and discovery of all WorldPlugin implementations.
- Import:
import { pluginRegistry } from "@/core/plugins/PluginRegistry"; - Source:
src/core/plugins/PluginRegistry.ts
Adds a new plugin to the registry. Throws a warning if the plugin ID is already registered.
Retrieves a plugin by its unique ID.
Returns an array of all registered plugins.
Returns all plugins belonging to a specific category.
Checks if a plugin with the given ID is registered.
Removes a plugin from the registry.
The CacheLayer provides a two-tier caching mechanism for geographical entities.
- Import:
import { cacheLayer } from "@/core/data/CacheLayer"; - Source:
src/core/data/CacheLayer.ts
Initializes the IndexedDB store. Must be called before persistent storage operations.
Caches entities for a plugin.
- pluginId: Unique identifier for the data source.
- entities: Array of
GeoEntityobjects. - ttlMs: Time-to-live in milliseconds (default: 30,000).
Retrieves entities from the L1 (Memory) cache. Returns null if expired or missing.
Retrieves entities from the L2 (IndexedDB) cache. This method also populates the L1 cache on success.
Removes entries for a plugin from both L1 and L2 caches.
Purges all data from both cache tiers.