How to use the codesandbox-api.dispatch function in codesandbox-api

To help you get started, we’ve selected a few codesandbox-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codesandbox / codesandbox-client / packages / app / src / sandbox / eval / transpiled-module.ts View on Github external
this.warnings.forEach(warning => {
        console.warn(warning.message); // eslint-disable-line no-console
        dispatch(
          actions.correction.show(warning.message, {
            line: warning.lineNumber,
            column: warning.columnNumber,
            path: warning.path,
            source: warning.source,
            severity: warning.severity || 'warning',
          })
        );
      });
    }
github codesandbox / codesandbox-client / packages / app / src / sandbox / compile-old.js View on Github external
if (!initializedResizeListener) {
      initializeResizeListener();
    }

    // Testing
    const ttt = Date.now();
    const testRunner = manager.testRunner;
    try {
      testRunner.initialize();
      testRunner.findTests(modules);
      await testRunner.runTests();
      const aggregatedResults = testRunner.reportResults();
      debug(`Test Evaluation time: ${Date.now() - ttt}ms`);

      dispatch({
        type: 'test-result',
        result: Encode(aggregatedResults),
      });
      // End - Testing
    } catch (error) {
      dispatch({
        type: 'test-result',
        error: testRunner.reportError(error),
      });
    }

    debug(`Total time: ${Date.now() - startTime}ms`);

    dispatch({
      type: 'success',
    });
github codesandbox / codesandbox-client / packages / app / src / sandbox / compile.ts View on Github external
const main = absolute(foundMain);
    managerModuleToTranspile = modules[main];

    // TODO: make this a separate lifecycle
    // await manager.preset.setup(manager);

    dispatch({ type: 'status', status: 'transpiling' });
    manager.setStage('transpilation');

    await manager.verifyTreeTranspiled();
    await manager.transpileModules(managerModuleToTranspile);

    debug(`Transpilation time ${Date.now() - t}ms`);

    dispatch({ type: 'status', status: 'evaluating' });
    manager.setStage('evaluation');

    if (!skipEval) {
      resetScreen();

      try {
        // We set it as a time value for people that run two sandboxes on one computer
        // they execute at the same time and we don't want them to conflict, so we check
        // if the message was set a second ago
        if (
          firstLoad &&
          localStorage.getItem('running') &&
          Date.now() - +localStorage.getItem('running') > 8000
        ) {
          localStorage.removeItem('running');
          showRunOnClick();
github codesandbox / codesandbox-client / packages / sandbox-hooks / errors / index.js View on Github external
export default function showError(ref: ErrorRecord) {
  const errorToSend = buildDynamicError(ref);

  if (errorToSend) {
    dispatch(
      actions.error.show(errorToSend.title, errorToSend.message, {
        line: errorToSend.line,
        column: errorToSend.column,
        path: errorToSend.path,
        payload: errorToSend.payload,
      })
    );
  } else {
    // Show based on error
    actions.error.show(ref.error.name, ref.error.message, {
      line: ref.error.lineNumber,
      column: ref.error.columnNumber,
      path: ref.error.fileName,
      payload: {},
    });
  }
github codesandbox / codesandbox-client / packages / executors / src / serverExecutor.ts View on Github external
function sseTerminalMessage(msg: string) {
  dispatch({
    type: 'terminal:message',
    data: `> Sandbox Container: ${msg}\n\r`,
  });
}
github codesandbox / codesandbox-client / src / sandbox / url-listeners.js View on Github external
function sendUrlChange(url: string) {
  dispatch({
    type: 'urlchange',
    url,
  });
}
github codesandbox / codesandbox-client / packages / sandbox-hooks / errors / transformers / raw-react-component-error.js View on Github external
action: () => {
              dispatch(
                actions.source.modules.rename(
                  rawModule.module.path,
                  `${basename(rawModule.module.path)}.js`
                )
              );
            },
          },
github codesandbox / codesandbox-client / packages / app / src / sandbox / compile.ts View on Github external
function sendResize() {
  const height = getDocumentHeight();

  if (lastHeight !== height) {
    if (document.body) {
      dispatch({
        type: 'resize',
        height,
      });
    }
  }

  lastHeight = height;
}

codesandbox-api

[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![Greenkeeper badge](https://badges.greenkeeper.io/alexjoverm/typescript-library-starter.svg)](https://greenkeeper.io/) [![Travi

MIT
Latest version published 4 years ago

Package Health Score

73 / 100
Full package analysis

Similar packages