MCPcopy
hub / github.com/JoelOtter/kajero / executeCodeBlock

Function executeCodeBlock

src/js/actions.js:76–103  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

74}
75
76export function executeCodeBlock (id) {
77 return (dispatch, getState) => {
78 const code = getState().notebook.getIn(['blocks', id, 'content']);
79 const graphElement = document.getElementById("kajero-graph-" + id);
80
81 const executionState = getState().execution;
82 const context = executionState.get('executionContext').toJS();
83 const data = executionState.get('data').toJS();
84 const jutsu = Smolder(Jutsu(graphElement));
85
86 return new Promise((resolve, reject) => {
87 try {
88 const result = new Function(
89 ['d3', 'nv', 'graphs', 'data', 'reshaper', 'graphElement'], code
90 ).call(
91 context, d3, nv, jutsu, data, reshaper, graphElement
92 );
93 resolve(result);
94 } catch(err) {
95 reject(err);
96 }
97 })
98 .then((result) => dispatch(
99 codeExecuted(id, result, Immutable.fromJS(context))
100 ))
101 .catch((err) => dispatch(codeError(id, err)));
102 };
103}
104
105function codeExecuted(id, result, context) {
106 return {

Callers 5

clickPlayMethod · 0.90
componentDidMountMethod · 0.90
componentDidMountFunction · 0.90
componentDidUpdateFunction · 0.90
executeAutoFunction · 0.85

Calls 2

codeExecutedFunction · 0.85
codeErrorFunction · 0.85

Tested by

no test coverage detected