src/actions.js: Managing Data Flow and User Interactions
The src/actions.js file is integral to the SILAS Web demo app, orchestrating data management and user interactions. It defines actions that facilitate operations like loading data, exporting maps, and interacting with cloud providers. These actions are dispatched from components such as src/app.js to alter the application's state and initiate specific behaviors.
1. Action Creators
This file includes several action creators, each tasked with generating an action object containing a specific type and payload. These action objects are dispatched to the Redux store, which updates the application's state accordingly.
1.1. loadRemoteMap
- Purpose: Initiates data loading from a remote URL.
- Payload:
dataUrl: The URL of the data source.
- Action Type:
LOAD_REMOTE_MAP - Effect: Initiates a data loading process from the specified URL and integrates the loaded data into the Kepler.gl map.
1.2. loadSampleConfigurations
- Purpose: Loads a predefined sample dataset configuration.
- Payload:
id: The identifier of the sample dataset to load.
- Action Type:
LOAD_SAMPLE_CONFIGURATIONS - Effect: Loads the specified sample dataset configuration and integrates the data into the Kepler.gl map.
1.3. onExportFileSuccess
- Purpose: Manages the successful export of a map to a cloud provider.
- Payload:
provider: The cloud provider used for export.options: Options related to the export process.
- Action Type:
EXPORT_FILE_SUCCESS - Effect: Updates the application state to reflect the successful map export.
1.4. onLoadCloudMapSuccess
- Purpose: Manages the successful loading of a map from a cloud provider.
- Payload:
provider: The cloud provider used for loading.loadParams: Parameters for loading the map.
- Action Type:
LOAD_CLOUD_MAP_SUCCESS - Effect: Updates the application state to reflect the successful map loading.
2. Data Processing
The processGeometryData function processes data containing geometry information, extracting geometry objects and converting them into a GeoJSON-like format for easier visualization in Kepler.gl.
3. Example Process
Consider a JSON data file available at a URL. The loadRemoteMap action is dispatched with this URL, triggering a series of operations: the data is fetched, processed by processGeometryData, and then loaded into the Kepler.gl map, updating the application's state to reflect the new data.