@@ -41,7 +41,7 @@ import {createAction, Action} from 'redux-actions';
4141import { addHttpHeaders } from '../actions' ;
4242import { notifyObservers , updateProps } from './index' ;
4343import { CallbackJobPayload } from '../reducers/callbackJobs' ;
44- import { handlePatch , isPatch , parsePatchProps } from './patch' ;
44+ import { parsePatchProps } from './patch' ;
4545import { computePaths , getPath } from './paths' ;
4646
4747import { requestDependencies } from './requestDependencies' ;
@@ -818,12 +818,23 @@ export function executeCallback(
818818
819819 if ( clientside_function ) {
820820 try {
821- const data = await handleClientside (
821+ let data = await handleClientside (
822822 dispatch ,
823823 clientside_function ,
824824 config ,
825825 payload
826826 ) ;
827+ // Patch methodology: always run through parsePatchProps for each output
828+ const currentLayout = getState ( ) . layout ;
829+ flatten ( outputs ) . forEach ( ( out : any ) => {
830+ const propName = cleanOutputProp ( out . property ) ;
831+ const outputPath = getPath ( paths , out . id ) ;
832+ const dataPath = [ stringifyId ( out . id ) , propName ] ;
833+ const outputValue = path ( dataPath , data ) ;
834+ const oldProps = path ( outputPath . concat ( [ 'props' ] ) , currentLayout ) || { } ;
835+ const newProps = parsePatchProps ( { [ propName ] : outputValue } , oldProps ) ;
836+ data = assocPath ( dataPath , newProps [ propName ] , data ) ;
837+ } ) ;
827838 return { data, payload} ;
828839 } catch ( error : any ) {
829840 return { error, payload} ;
@@ -882,26 +893,16 @@ export function executeCallback(
882893 dispatch ( addHttpHeaders ( newHeaders ) ) ;
883894 }
884895 // Layout may have changed.
896+ // DRY: Always run through parsePatchProps for each output
885897 const currentLayout = getState ( ) . layout ;
886898 flatten ( outputs ) . forEach ( ( out : any ) => {
887899 const propName = cleanOutputProp ( out . property ) ;
888900 const outputPath = getPath ( paths , out . id ) ;
889- const previousValue = path (
890- outputPath . concat ( [ 'props' , propName ] ) ,
891- currentLayout
892- ) ;
893901 const dataPath = [ stringifyId ( out . id ) , propName ] ;
894902 const outputValue = path ( dataPath , data ) ;
895- if ( isPatch ( outputValue ) ) {
896- if ( previousValue === undefined ) {
897- throw new Error ( 'Cannot patch undefined' ) ;
898- }
899- data = assocPath (
900- dataPath ,
901- handlePatch ( previousValue , outputValue ) ,
902- data
903- ) ;
904- }
903+ const oldProps = path ( outputPath . concat ( [ 'props' ] ) , currentLayout ) || { } ;
904+ const newProps = parsePatchProps ( { [ propName ] : outputValue } , oldProps ) ;
905+ data = assocPath ( dataPath , newProps [ propName ] , data ) ;
905906 } ) ;
906907
907908 if ( dynamic_creator ) {
0 commit comments