kgabryje commented on code in PR #31331:
URL: https://github.com/apache/superset/pull/31331#discussion_r2020609005


##########
superset-frontend/src/embedded/index.tsx:
##########
@@ -51,11 +52,27 @@ const LazyDashboardPage = lazy(
     ),
 );
 
+const EmbededLazyDashboardPage = () => {
+  const uiConfig = useUiConfig();
+
+  // Emit data mask changes to the parent window
+  if (uiConfig?.emitDataMasks) {
+    log('setting up Switchboard event emitter');
+
+    store.subscribe(() => {
+      const state = store.getState();
+      Switchboard.emit('getDataMasks', state.dataMask);

Review Comment:
   This will emit `getDataMask` on every change in the store, resulting in many 
redundant calls. Can we emit only when the dataMask changes, like this:
   ```
   if (uiConfig?.emitDataMasks) {
       log('setting up Switchboard event emitter');
   
       let previousDataMask = store.getState().dataMask;
       
       store.subscribe(() => {
         const currentState = store.getState();
         const currentDataMask = currentState.dataMask;
         
         // Only emit if the dataMask has changed
         if (previousDataMask !== currentDataMask) {
           Switchboard.emit('getDataMasks', currentDataMask);
           previousDataMask = currentDataMask;
         }
       });
     }
     ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to