MCPcopy Index your code
hub / github.com/apache/echarts / dispatchAction

Function dispatchAction

src/component/brush/visualEncoding.ts:241–284  ·  view source on GitHub ↗
(
    api: ExtensionAPI,
    throttleType: throttleUtil.ThrottleType,
    throttleDelay: number,
    brushSelected: BrushSelectedItem[],
    payload: Payload
)

Source from the content-addressed store, hash-verified

239};
240
241function dispatchAction(
242 api: ExtensionAPI,
243 throttleType: throttleUtil.ThrottleType,
244 throttleDelay: number,
245 brushSelected: BrushSelectedItem[],
246 payload: Payload
247): void {
248 // This event will not be triggered when `setOption`, otherwise dead lock may
249 // triggered when do `setOption` in event listener, which we do not find
250 // satisfactory way to solve yet. Some considered resolutions:
251 // (a) Diff with previous selected data ant only trigger event when changed.
252 // But store previous data and diff precisely (i.e., not only by dataIndex, but
253 // also detect value changes in selected data) might bring complexity or fragility.
254 // (b) Use special param like `silent` to suppress event triggering.
255 // But such kind of volatile param may be weird in `setOption`.
256 if (!payload) {
257 return;
258 }
259
260 // FIXME: [INCONSISTENCY_OF_BRUSH_SELECTED_EVENT_IN_UPDATE_TRANSFORM]
261 // If any series declared in ec option does not support `updateTransform`, `updateTransform` will
262 // dirty the pipeline (see `echarts.ts`), thereby `reset` of `brush/visualEncoding.ts` being called,
263 // and then 'brushselected' event is triggered here.
264 // If all series declared in ec option support `updateTransform` and return no 'update', the pipeline
265 // will not be dirty, consequently `reset` is not called and 'brushselected' event is not triggered.
266 // This inconsistency is unreasonable and error-prone.
267 // Theoretically, 'brushselected' should always be triggered, since the "brush covers" may stay at its
268 // original place even when roaming (depending on settings). But we should not use `dirtyOnOverallProgress`
269 // in this visual task, otherwise all pipelines will be blocked and progressive rendering is broken.
270 // Therefore, the mechanism of `updateTranform` and `updateVisual` needs to review and refactor.
271
272 const zr = api.getZr() as BrushGlobalDispatcher;
273 if (zr[DISPATCH_FLAG]) {
274 return;
275 }
276
277 if (!zr[DISPATCH_METHOD]) {
278 zr[DISPATCH_METHOD] = doDispatch;
279 }
280
281 const fn = throttleUtil.createOrUpdate(zr, DISPATCH_METHOD, throttleDelay, throttleType);
282
283 fn(api, brushSelected);
284}
285
286function doDispatch(api: ExtensionAPI, brushSelected: BrushSelectedItem[]): void {
287 if (!api.isDisposed()) {

Callers 1

brushVisualFunction · 0.70

Calls 2

fnFunction · 0.85
getZrMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…