()
| 147 | } |
| 148 | |
| 149 | export function fetchData() { |
| 150 | return (dispatch, getState) => { |
| 151 | let proms = []; |
| 152 | const currentData = getState().execution.get('data'); |
| 153 | getState().notebook.getIn(['metadata', 'datasources']).forEach( |
| 154 | (url, name) => { |
| 155 | if (!currentData.has(name)) { |
| 156 | proms.push( |
| 157 | fetch(url, { |
| 158 | method: 'get' |
| 159 | }) |
| 160 | .then(response => response.json()) |
| 161 | .then(j => dispatch(receivedData(name, j))) |
| 162 | ); |
| 163 | } |
| 164 | } |
| 165 | ); |
| 166 | // When all data fetched, run all the auto-running code blocks. |
| 167 | return Promise.all(proms).then(() => dispatch(executeAuto())); |
| 168 | }; |
| 169 | } |
| 170 | |
| 171 | export function toggleEdit() { |
| 172 | return { |
no test coverage detected