preProcessor: ({data}) => {
for (const feature of data) {
feature.properties.selected = selectedFeatureIds.has(feature.id);
}
return data;
}
selectedFeatureIds is application state accessible on the main thread.
preProcessor: {
execution: 'worker',
options: {minHeight: 10},
processor: ({data}, {options}) => {
return data.filter((feature) =>
feature.properties.height >= Number(options.minHeight)
);
}
}
The worker function is standalone and returns the processed features.
preProcessor: {
worker: {
options: {minHeight: 10},
processor: ({data}, {options}) => {
return data.filter((feature) =>
feature.properties.height >= Number(options.minHeight)
);
}
},
main: ({data}) => {
for (const feature of data) {
feature.properties.selected = selectedFeatureIds.has(feature.id);
}
return data;
}
}
Worker filtering completes before main-thread access to application state.
Configure remote data preprocessing using a main-thread function (PreProcessor), sequential worker and main-thread phases (PreProcessorPipelineOptions), or a single worker processor (WorkerPreProcessorOptions).