assets/exercises.js
function(data, eventType) {
            switch(eventType) {
                case 'progress':
                    // Update UI loading bar
                    break;
                case 'timeout':
                    finish(new Error(data));
                    break;
                case 'result':
                    finish(null, {
                        value: data,
                        type: 'result'
                    });
                    break;
                case 'error':
                    if(ready) {
                        return finish(null, {
                            value: data,
                            type: 'error'
                        });
                    }
                    return finish(new Error(data));
                    break
                case 'ready':
                    // We're good to get results and stuff back now
                    ready = true;
                    // Eval our code now that the runtime is ready
                    repl.eval(code);
                    break;
                default:
                    console.log('Unhandled event =', eventType, 'data =', data);
            }
        }
function(data, eventType) {
            switch(eventType) {
                case 'progress':
                    // Update UI loading bar
                    break;
                case 'timeout':
                    finish(new Error(data));
                    break;
                case 'result':
                    finish(null, {
                        value: data,
                        type: 'result'
                    });
                    break;
                case 'error':
                    if(ready) {
                        return finish(null, {
                            value: data,
                            type: 'error'
                        });
                    }
                    return finish(new Error(data));
                    break
                case 'ready':
                    // We're good to get results and stuff back now
                    ready = true;
                    // Eval our code now that the runtime is ready
                    repl.eval(code);
                    break;
                default:
                    console.log('Unhandled event =', eventType, 'data =', data);
            }
        }
function ( data , eventType ) { switch ( eventType ) { case 'progress' : // Update UI loading bar break ; case 'timeout' : finish ( new Error ( data ) ) ; break ; case 'result' : finish ( null , { value : data , type : 'result' } ) ; break ; case 'error' : if ( ready ) { return finish ( null , { value : data , type : 'error' } ) ; } return finish ( new Error ( data ) ) ; break case 'ready' : // We're good to get results and stuff back now ready = true ; // Eval our code now that the runtime is ready repl . eval ( code ) ; break ; default : console . log ( 'Unhandled event =' , eventType , 'data =' , data ) ; } }
Handles all our events
Handles all our events