michael-s-molina commented on code in PR #34874:
URL: https://github.com/apache/superset/pull/34874#discussion_r2307224477


##########
superset-frontend/packages/superset-ui-core/src/chart/components/SuperChartCore.tsx:
##########
@@ -89,27 +89,76 @@ export default class SuperChartCore extends 
PureComponent<Props, {}> {
    * and return previous value
    * unless one of
    * - preTransformProps
-   * - transformProps
-   * - postTransformProps
    * - chartProps
    * is changed.
    */
-  processChartProps = createSelector(
+  preSelector = createSelector(
     [
       (input: {
         chartProps: ChartProps;
         preTransformProps?: PreTransformProps;
-        transformProps?: TransformProps;
-        postTransformProps?: PostTransformProps;
       }) => input.chartProps,
       input => input.preTransformProps,
+    ],
+    (chartProps, pre = IDENTITY) => pre(chartProps),
+  );
+
+  /**
+   * memoized function so it will not recompute
+   * and return previous value
+   * unless one of
+   * - transformProps
+   * - preprocessed result
+   * is changed.
+   */
+  transformSelector = createSelector(
+    [
+      (input: { chartProps: ChartProps; transformProps?: TransformProps }) =>
+        input.chartProps,
       input => input.transformProps,
+    ],
+    (preprocessedChartProps, transform = IDENTITY) =>
+      transform(preprocessedChartProps),
+  );
+
+  /**
+   * memoized function so it will not recompute
+   * and return previous value
+   * unless one of
+   * - postTransformProps
+   * - transformed result
+   * is changed.
+   */
+  postSelector = createSelector(
+    [
+      (input: {
+        chartProps: ChartProps;
+        postTransformProps?: PostTransformProps;
+      }) => input.chartProps,
       input => input.postTransformProps,
     ],
-    (chartProps, pre = IDENTITY, transform = IDENTITY, post = IDENTITY) =>
-      post(transform(pre(chartProps))),
+    (transformedChartProps, post = IDENTITY) => post(transformedChartProps),
   );
 
+  processChartProps = ({

Review Comment:
   Could you add a docstring for this function?



##########
superset-frontend/packages/superset-ui-core/src/chart/components/SuperChartCore.test.tsx:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { render, waitFor } from '@testing-library/react';
+
+import {
+  ChartPlugin,
+  ChartMetadata,
+  DatasourceType,
+  getChartComponentRegistry,
+} from '@superset-ui/core';
+
+import SuperChartCore from './SuperChartCore';
+
+describe('processChartProps', () => {

Review Comment:
   Could you use `test` instead of `describe/it`?



##########
superset-frontend/packages/superset-ui-core/src/chart/components/SuperChartCore.tsx:
##########
@@ -89,27 +89,76 @@ export default class SuperChartCore extends 
PureComponent<Props, {}> {
    * and return previous value
    * unless one of
    * - preTransformProps
-   * - transformProps
-   * - postTransformProps
    * - chartProps
    * is changed.
    */
-  processChartProps = createSelector(
+  preSelector = createSelector(
     [
       (input: {
         chartProps: ChartProps;
         preTransformProps?: PreTransformProps;
-        transformProps?: TransformProps;
-        postTransformProps?: PostTransformProps;
       }) => input.chartProps,
       input => input.preTransformProps,
+    ],
+    (chartProps, pre = IDENTITY) => pre(chartProps),
+  );
+
+  /**

Review Comment:
   Could you adjust the comments for `transformSelector` and `postSelector` to:
   
   > Memoized the function so it will not recompute and return the previous 
value unless one of the input arguments have changed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to