An easy-to-use platform for EEG experimentation in the classroom
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fixed issues with pyodide not loading;

authored by

jdpigeon and committed by
Teon L Brooks
e76d27c5 d205f09d

+29 -8
+7 -1
app/containers/HomeContainer.ts
··· 3 3 import Home from '../components/HomeComponent'; 4 4 import { DeviceActions, ExperimentActions, PyodideActions } from '../actions'; 5 5 6 + function mapStateToProps(state) { 7 + return { 8 + ...state.device, 9 + }; 10 + } 11 + 6 12 function mapDispatchToProps(dispatch) { 7 13 return { 8 14 DeviceActions: bindActionCreators(DeviceActions, dispatch), ··· 11 17 }; 12 18 } 13 19 14 - export default connect(mapDispatchToProps)(Home); 20 + export default connect(mapStateToProps, mapDispatchToProps)(Home);
+22 -7
app/epics/pyodideEpics.ts
··· 1 1 import { combineEpics, Epic } from 'redux-observable'; 2 - import { of } from 'rxjs'; 2 + import Rx, { fromEvent, Observable, ObservableInput, of } from 'rxjs'; 3 3 import { map, mergeMap, tap, pluck, filter } from 'rxjs/operators'; 4 4 import { toast } from 'react-toastify'; 5 5 import { isActionOf } from '../utils/redux'; ··· 43 43 map(PyodideActions.SetPyodideWorker) 44 44 ); 45 45 46 - const pyodideError: Epic<PyodideActionType, PyodideActionType, RootState> = ( 47 - action$ 48 - ) => 46 + const pyodideErrorEpic: Epic< 47 + PyodideActionType, 48 + PyodideActionType, 49 + RootState 50 + > = (action$) => 49 51 action$.pipe( 50 52 filter(isActionOf(PyodideActions.SetPyodideWorker)), 51 53 pluck('payload'), 54 + mergeMap<Worker, Observable<any>>((worker) => { 55 + return fromEvent(worker, 'error'); 56 + }), 52 57 tap((e) => 53 58 toast.error( 54 59 `Error in pyodideWorker at ${e.filename}, Line: ${e.lineno}, ${e.message}` ··· 57 62 map(PyodideActions.ReceiveError) 58 63 ); 59 64 60 - const receiveChannelMessageEpic: Epic< 65 + // Once pyodide webworker is created, 66 + // Create an observable of events that corresond to what it retjurns 67 + // and then emite those events as redux actions 68 + const pyodideMessageEpic: Epic< 61 69 PyodideActionType, 62 70 PyodideActionType, 63 71 RootState 64 - > = (action$, state$) => 72 + > = (action$) => 65 73 action$.pipe( 66 74 filter(isActionOf(PyodideActions.SetPyodideWorker)), 75 + pluck('payload'), 76 + mergeMap<Worker, Observable<any>>((worker) => { 77 + return fromEvent(worker, 'message'); 78 + }), 67 79 tap((e) => { 80 + console.log(e); 68 81 const { results, error } = e.data; 82 + 69 83 if (results && !error) { 70 84 toast(`Pyodide: `, results); 71 85 } else if (error) { ··· 233 247 234 248 export default combineEpics( 235 249 launchEpic, 236 - receiveChannelMessageEpic, 250 + pyodideMessageEpic, 251 + pyodideErrorEpic, 237 252 loadEpochsEpic, 238 253 loadCleanedEpochsEpic, 239 254 cleanEpochsEpic,