fix: after fixing syntax errors in editor for JS/React lessons, log/preview doesn't work.

This commit is contained in:
ValeraS
2018-07-04 16:38:42 +03:00
committed by Mrugesh Mohapatra
parent 1b173bc97c
commit ae02b0a885
4 changed files with 6 additions and 11 deletions

View File

@ -87,7 +87,7 @@ function tryTransform(wrap = identity) {
// At the minute, it will not bubble up // At the minute, it will not bubble up
// We collapse the pipeline so the app doesn't fall over trying // We collapse the pipeline so the app doesn't fall over trying
// parse bad code (syntax/type errors etc...) // parse bad code (syntax/type errors etc...)
throw new Error(); throw result;
} }
return result; return result;
}; };

View File

@ -3,7 +3,7 @@ import { ofType } from 'redux-observable';
import { types, unlockCode } from './'; import { types, unlockCode } from './';
function codeLockEpic(action$) { function codeLockEpic(action$) {
return action$.pipe(ofType(types.executeChallenge), map(unlockCode)); return action$.pipe(ofType(types.updateFile), map(unlockCode));
} }
export default codeLockEpic; export default codeLockEpic;

View File

@ -50,7 +50,6 @@ function updateMainEpic(actions, { getState }, { document }) {
const buildAndFrameMain = actions.pipe( const buildAndFrameMain = actions.pipe(
ofType( ofType(
types.updateFile, types.updateFile,
types.executeChallenge,
types.challengeMounted types.challengeMounted
), ),
debounceTime(executeDebounceTimeout), debounceTime(executeDebounceTimeout),
@ -58,6 +57,7 @@ function updateMainEpic(actions, { getState }, { document }) {
buildFromFiles(getState(), true).pipe( buildFromFiles(getState(), true).pipe(
map(frameMain), map(frameMain),
ignoreElements(), ignoreElements(),
startWith(initConsole('')),
catchError(err => of(disableJSOnError(err))) catchError(err => of(disableJSOnError(err)))
) )
) )

View File

@ -106,13 +106,7 @@ export const updateSuccessMessage = createAction(types.updateSuccessMessage);
export const lockCode = createAction(types.lockCode); export const lockCode = createAction(types.lockCode);
export const unlockCode = createAction(types.unlockCode); export const unlockCode = createAction(types.unlockCode);
export const disableJSOnError = createAction( export const disableJSOnError = createAction(types.disableJSOnError);
types.disableJSOnError,
({ payload }) => {
console.error(JSON.stringify(payload));
return null;
}
);
export const storedCodeFound = createAction(types.storedCodeFound); export const storedCodeFound = createAction(types.storedCodeFound);
export const noStoredCodeFound = createAction(types.noStoredCodeFound); export const noStoredCodeFound = createAction(types.noStoredCodeFound);
@ -222,8 +216,9 @@ export const reducer = handleActions(
isJSEnabled: true, isJSEnabled: true,
isCodeLocked: false isCodeLocked: false
}), }),
[types.disableJSOnError]: state => ({ [types.disableJSOnError]: (state, { payload }) => ({
...state, ...state,
consoleOut: state.consoleOut + '\n' + payload,
isJSEnabled: false isJSEnabled: false
}), }),